码迷,mamicode.com
首页 > 其他好文 > 详细

让妖梦酱抓狂的澈夕雅——花妖之章4

时间:2017-05-19 23:47:37      阅读:258      评论:0      收藏:0      [点我收藏+]

标签:out   position   释放   change   magic   owa   err   player   rand   

剧本完成之后就可以写代码了


using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

namespace Saruka.Character.Restina
{
/// <summary>
/// 蕾丝缇娜,第一关boss
/// </summary>
public class RestinaRosedoll : Boss
{
/// <summary>
/// 是否踩在荆棘园上面
/// </summary>
public bool getOnRoseGarden = false;
public Vector2 center;
internal bool Phase4 = false;
internal List<Vector2> Phase4MagicalRoseLocation = new List<Vector2>();
internal int PlayerGetinId;
internal int phase4TotalLife = 1;
public RestinaAttractivePart shadowPart;
GameObject wall;
internal void Phase4Recover()
{
if (Phase4)
{
base.life++;
}
}

public override int life
{
get
{
return base.life;
}
set
{
if (!Phase4)
{
base.life = value;
}
}
}

#region 面向

/// <summary>
/// 面向(和X轴夹角)
/// </summary>
public override float facef
{
get
{
return transform.FindChild("TargetRing").eulerAngles.z;
}

set
{
transform.FindChild("TargetRing").eulerAngles = new Vector3(0, 0, value);
}
}

public void MoveFrame()
{
transform.position += (Vector3)face * 3f * moveSpeedRate * Time.deltaTime;
}

/// <summary>
/// 面向(瞄准方向)
/// </summary>
public override Vector2 face
{
get
{
return new Vector2(Mathf.Cos(transform.FindChild("TargetRing").eulerAngles.z * Mathf.Deg2Rad), Mathf.Sin(transform.FindChild("TargetRing").eulerAngles.z * Mathf.Deg2Rad));
}
set
{
value.Normalize();
float qw = Mathf.Sqrt(2 + 2 * value.x) / 2;
if (qw == 0)
{
transform.FindChild("TargetRing").rotation = new Quaternion(0, 0, 1, 0);
}
else
{
float qz = value.y / (2 * qw);
transform.FindChild("TargetRing").rotation = new Quaternion(0, 0, qz, qw);
}
}
}

#endregion

#region 基本行为
// Use this for initialization
void Start()
{
Initialization();
}

// Update is called once per frame
void Update()
{
Refresh();
if (interrupt == 0)
{
stateMachine.Refresh();
}

}
public const int skillRoundAttack = 1;
public const int skillCrazyGrow = 0;
public const int skillSavageStorm = 2;
public const int skillAttractiveVoice = 3;
public const int skillMagicBlast = 4;
public const int skillDodgeMove = 5;
public const int skillAttractiveSight = 6;
public const int skillRoseCreep = 7;
public const int skillNormalAttackA = 8;
public const int skillNormalAttackC = 9;
protected new void Initialization()
{
base.Initialization();

skillSystem.skillList = new Skill[10];
skillSystem.skillList[0] = new SkillRestinaCrazyGrow(2);
skillSystem.skillList[1] = new SkillRestinaRoundAttack();
skillSystem.skillList[2] = new SkillRestinaSavageStorm();
skillSystem.skillList[3] = new SkillRestinaAttractiveVoice();
skillSystem.skillList[4] = new SkillRestinaMagicBlast();
skillSystem.skillList[5] = new SkillRestinaDodgeMove();
skillSystem.skillList[6] = new SkillRestinaAttractiveSight();
skillSystem.skillList[7] = new SkillRestinaRoseCreep();
skillSystem.skillList[8] = new SkillRestinaNormalAttackA();
skillSystem.skillList[9] = new SkillNormalAttackC();
wall = Instantiate(GameCreaterYoomu.gameObjects["ScapeWallBattleField"], transform.position, Quaternion.identity);
center = transform.position;
StateDodgetoCenter.center = transform.position;

//初始化阶段

OnChangeStage += ChangeP;
if (GameManager.difficulty == Difficulty.Savage)
{
lifeMaxPerStage = new int[4] { 3000, 3000, 3000, 7000 };
life = lifeMax = lifeMaxPerStage[0];
mana = manaMax = 100;
hitRecovery = hitRecoveryMax = 250;
hitRecoveryRecoverSpeed = 125;
stateMachine.currentState = new StateNullState();
//SavageInitPhase1();
}
else
{
lifeMaxPerStage = new int[2] { 2000, 4000 };
life = lifeMax = lifeMaxPerStage[0];
mana = manaMax = 100;
hitRecovery = hitRecoveryMax = 250;
hitRecoveryRecoverSpeed = 125;
stateMachine.currentState = new StateNullState();
//NormalPhase1Init();
}
}

#endregion

/// <summary>
/// 转阶段
/// </summary>
private void ChangeP(object sender, StageChangingEventArgs e)
{
switch (e.NewStage)
{
case 1:
{
Debug.Log("P2");
if (GameManager.difficulty == Difficulty.Normal)
{
NormalPhase2Init();
}
else
{
Phase2Init(sender);
}

}
break;
case 2:
{
Debug.Log("P3");
Phase3Init();
}
break;
case 3:
Phase4Init();
break;
default:
break;
}
}

 

}

#region 蕾丝缇娜技能

/// <summary>
/// 蕾丝缇娜技能模板
/// </summary>
abstract class SkillRestina : Skill
{
public bool casting = false;
public override void Enter(Creature owner)
{
casting = true;
}
public override void Exit(Creature owner)
{
casting = false;
}
}

/// <summary>
/// 狂暴生长
/// </summary>
class SkillRestinaCrazyGrow : SkillRestina
{
public Vector3 targetLocation;
public GameObject[] EffectCrazyGrow = new GameObject[4];
public GameObject CrazyGrowAndRoseGarden;
public Vector3[] targetLocationArea = new Vector3[4];
public int Phase4RoseMax;
public SkillRestinaCrazyGrow(int Level)
{
totalCastingTime = 1.2f;
level = Level;
manaCost = 0;
totalColdDownTime = 0;
}

public override void Complete(Creature owner)
{

if (((RestinaRosedoll)owner).Phase4)
{
Debug.Log("nya");
for (int i = 0; i < Phase4RoseMax; i++)
{
CrazyGrowAndRoseGarden = UnityEngine.Object.Instantiate(GameCreaterYoomu.gameObjects["BulletCrazyGrow"], targetLocationArea[i], Quaternion.identity);
CrazyGrowAndRoseGarden.GetComponent<BulletCrazyGrow>().source = owner;
CrazyGrowAndRoseGarden.GetComponent<BulletCrazyGrow>().Savage = true;
CrazyGrowAndRoseGarden.GetComponent<BulletCrazyGrow>().damage = 150;
UnityEngine.Object.Destroy(CrazyGrowAndRoseGarden, 12);
}

GameObject attractiveVoice = UnityEngine.Object.Instantiate(GameCreaterYoomu.gameObjects["BulletAttractiveVoiceSavage"], owner.transform.position, Quaternion.identity);
attractiveVoice.transform.eulerAngles = new Vector3(0, 0, owner.facef);
attractiveVoice.GetComponent<BulletSavageAttractiveVoice>().source = owner;


}
else if (level >= 2)
{
Debug.Log("hh");
CrazyGrowAndRoseGarden = UnityEngine.Object.Instantiate(GameCreaterYoomu.gameObjects["BulletCrazyGrow"], targetLocation, Quaternion.identity);
CrazyGrowAndRoseGarden.GetComponent<BulletCrazyGrow>().source = owner;
CrazyGrowAndRoseGarden.GetComponent<BulletCrazyGrow>().Savage = true;
CrazyGrowAndRoseGarden.GetComponent<BulletCrazyGrow>().damage = 150;
UnityEngine.Object.Destroy(CrazyGrowAndRoseGarden, 15 * level - 1);
for (int i = 0; i < 4; i++)
{
Debug.Log(i);
CrazyGrowAndRoseGarden = UnityEngine.Object.Instantiate(GameCreaterYoomu.gameObjects["BulletCrazyGrow"], targetLocationArea[i], Quaternion.identity);
CrazyGrowAndRoseGarden.GetComponent<BulletCrazyGrow>().source = owner;
CrazyGrowAndRoseGarden.GetComponent<BulletCrazyGrow>().Savage = false;
CrazyGrowAndRoseGarden.GetComponent<BulletCrazyGrow>().damage = 150;
UnityEngine.Object.Destroy(CrazyGrowAndRoseGarden, 1);
}

}
else
{
Debug.Log("nya");
CrazyGrowAndRoseGarden.GetComponent<BulletCrazyGrow>().Savage = false;
CrazyGrowAndRoseGarden.GetComponent<BulletCrazyGrow>().damage = 100;
UnityEngine.Object.Destroy(CrazyGrowAndRoseGarden, 1);
}
}

public override void Enter(Creature owner)
{
base.Enter(owner);
Debug.Log("nyanya");
if (((RestinaRosedoll)owner).Phase4)
{
int max;
if (((RestinaRosedoll)owner).PlayerGetinId == -1)
{
max = ((RestinaRosedoll)owner).Phase4MagicalRoseLocation.Count;
}
else
{
max = ((RestinaRosedoll)owner).Phase4MagicalRoseLocation.Count - 1;
}
int avoidId = (int)((UnityEngine.Random.value * max) + 1 + ((RestinaRosedoll)owner).PlayerGetinId) % ((RestinaRosedoll)owner).Phase4MagicalRoseLocation.Count;
Phase4RoseMax = max - 1;
for (int i = 0; i < max - 1; i++)
{
if (i >= avoidId)
{
targetLocationArea[i] = ((RestinaRosedoll)owner).Phase4MagicalRoseLocation[i + 1];
}
else
{
targetLocationArea[i] = ((RestinaRosedoll)owner).Phase4MagicalRoseLocation[i];
}
EffectCrazyGrow[i] = GameObject.Instantiate(GameCreaterYoomu.gameObjects["EffectCrazyGrow"], targetLocationArea[i], Quaternion.identity);
GameObject.Destroy(EffectCrazyGrow[i], totalCastingTime);
}
}
else if (level == 1)
{
EffectCrazyGrow[0] = UnityEngine.Object.Instantiate(GameCreaterYoomu.gameObjects["EffectCrazyGrow"], targetLocation, Quaternion.identity);
UnityEngine.Object.Destroy(EffectCrazyGrow[0], totalCastingTime);
}
else
{
for (int i = 0; i < 4; i++)
{
float r = UnityEngine.Random.value;
targetLocationArea[i] = new Vector2(1.7f * Mathf.Sin(r * Mathf.PI * 2f), 1.7f * Mathf.Cos(r * Mathf.PI * 2f)) + (Vector2)targetLocation;
EffectCrazyGrow[i] = GameObject.Instantiate(GameCreaterYoomu.gameObjects["EffectCrazyGrow"], targetLocationArea[i], Quaternion.identity);
GameObject.Destroy(EffectCrazyGrow[i], totalCastingTime);
}
}
}

public override void Execute(Creature owner)
{

}

public override void Exit(Creature owner)
{
base.Exit(owner);
}
}

/// <summary>
/// 狂气风暴(Savage限定)
/// </summary>
class SkillRestinaSavageStorm : SkillRestina
{
GameObject SavageStormPV;
GameObject RoundAttack;
bool AorB;//位true时,释放A型,为false时,释放B型
public SkillRestinaSavageStorm()
{
totalCastingTime = 2f;
}
public override void Complete(Creature owner)
{
RoundAttack = GameObject.Instantiate(GameCreaterYoomu.gameObjects["BulletRoundAttack"], owner.transform.position, Quaternion.identity);
BulletRoundAttack b = RoundAttack.GetComponent<BulletRoundAttack>();
if (level == 2)
{
b.isSavageA = b.isSavageB = true;
}
else
{
b.isSavageA = AorB;
b.isSavageB = !AorB;
}

b.face = owner.facef;
b.damage = (int)(195 * owner.power);
b.source = owner;
b.Savage = true;
}

public override void Enter(Creature owner)
{
base.Enter(owner);
Debug.Log("enter");
AorB = UnityEngine.Random.value < 0.5;
if (AorB)
{
SavageStormPV = GameObject.Instantiate(GameCreaterYoomu.gameObjects["EffectCrazyGrow"], owner.transform.position, Quaternion.identity);
}
else
{
SavageStormPV = GameObject.Instantiate(GameCreaterYoomu.gameObjects["EffectSavageStormB"], owner.transform.position, Quaternion.identity);
}
}

public override void Execute(Creature owner)
{

}

public override void Exit(Creature owner)
{
base.Exit(owner);
GameObject.Destroy(SavageStormPV);
}
}

/// <summary>
/// 普攻C,Normal硬直朝外,Savage硬直朝内
/// </summary>
class SkillNormalAttackC : SkillRestina
{
bool attacking;
public SkillNormalAttackC()
{
totalCastingTime = 0.7f;

}

public override void Enter(Creature owner)
{
base.Enter(owner);
attacking = false;

}
public override void Complete(Creature owner)
{

}

public override void Execute(Creature owner)
{
if (!attacking)
{
if (castingTime < 0.4f)
{
attacking = true;
GameObject g = GameObject.Instantiate(GameCreaterYoomu.gameObjects["BulletNormalAttackC"], owner.transform.position, Quaternion.Euler(0, 0, owner.facef));
g.GetComponent<BulletNormalAttackC>().damage = (int)(80 * owner.power);
}
}
else
{
((RestinaRosedoll)owner).MoveFrame();
}
}
}

/// <summary>
/// 挥击
/// </summary>
class SkillRestinaRoundAttack : SkillRestina
{
int damage;
GameObject RoundAttack;
GameObject p;
public SkillRestinaRoundAttack()
{
totalCastingTime = 0.6f;
damage = GameManager.difficulty == Difficulty.Normal ? 145 : 195;
}

public override void Complete(Creature owner)
{
RoundAttack = UnityEngine.Object.Instantiate(GameCreaterYoomu.gameObjects["BulletRoundAttack"], owner.transform.position, Quaternion.identity);
BulletRoundAttack b = RoundAttack.GetComponent<BulletRoundAttack>();
b.Savage = false;
b.source = owner;
b.damage = damage;
}

public override void Enter(Creature owner)
{
base.Enter(owner);
p = UnityEngine.Object.Instantiate(GameCreaterYoomu.gameObjects["EffectCrazyGrow"], owner.transform.position, Quaternion.identity);
}

public override void Execute(Creature owner)
{

}

public override void Exit(Creature owner)
{
base.Exit(owner);
UnityEngine.Object.Destroy(p);
}
}

/// <summary>
/// 魅惑低语
/// </summary>
class SkillRestinaAttractiveVoice : SkillRestina
{
bool Savage = GameManager.difficulty == Difficulty.Savage;
GameObject attractiveVoiceP;
GameObject o;
GameObject attractiveVoice;
GameObject eff;

public SkillRestinaAttractiveVoice()
{
totalCastingTime = 1.8f;
}

public override void Enter(Creature owner)
{
base.Enter(owner);
if (Savage)
{
owner.facef = UnityEngine.Random.value * 90 - 45 + owner.facef;
if (level == 2)
{
eff = UnityEngine.Object.Instantiate(GameCreaterYoomu.gameObjects["EffectAttractiveSight"], owner.transform.position, Quaternion.identity);
}
}
else
{
attractiveVoiceP = UnityEngine.Object.Instantiate(GameCreaterYoomu.gameObjects["EffectAttractiveVoiceNormal"], owner.transform.position, Quaternion.identity);
attractiveVoiceP.transform.eulerAngles = new Vector3(0, 0, owner.facef);
}
o = UnityEngine.Object.Instantiate(GameCreaterYoomu.gameObjects["EffectCrazyGrow"], owner.transform.position, Quaternion.identity);
}

public override void Complete(Creature owner)
{
if (Savage)
{
attractiveVoice = UnityEngine.Object.Instantiate(GameCreaterYoomu.gameObjects["BulletAttractiveVoiceSavage"], owner.transform.position, Quaternion.identity);
attractiveVoice.transform.eulerAngles = new Vector3(0, 0, owner.facef);
attractiveVoice.GetComponent<BulletSavageAttractiveVoice>().source = owner;
if (level == 2)
{
if (GameManager.player != null)
{

Vector2 v = GameManager.player.transform.position - owner.transform.position;
if ((v.x == 0 && v.y == 0) || (GameManager.player.face.normalized - v.normalized).magnitude >= 1.7)
{
if (GameManager.difficulty == Difficulty.Savage)
{
GameManager.player.buffAddSingle(new DebuffAttractedSavage(10, owner, GameManager.player));
}
else
{
GameManager.player.buffAddSingle(new DebuffAttractedNormal(10, owner, GameManager.player));
}
}
}
}
}
else
{
attractiveVoice = UnityEngine.Object.Instantiate(GameCreaterYoomu.gameObjects["BulletAttractiveVoiceNormal"], owner.transform.position, Quaternion.identity);
attractiveVoice.transform.eulerAngles = attractiveVoiceP.transform.eulerAngles;
attractiveVoice.GetComponent<BulletNormalAttractiveVoice>().source = owner;
}
}

public override void Execute(Creature owner)
{

}

public override void Exit(Creature owner)
{
base.Exit(owner);
UnityEngine.Object.Destroy(attractiveVoiceP);
UnityEngine.Object.Destroy(o);
UnityEngine.Object.Destroy(eff);
}
}

/// <summary>
/// 魔力发散
/// </summary>
class SkillRestinaMagicBlast : SkillRestina
{
bool inout;//true为向内攻击,false为向外攻击
GameObject p;
GameObject bullet;
BulletMagicBlast m;
public SkillRestinaMagicBlast()
{
totalCastingTime = 3;
}

public override void Enter(Creature owner)
{
base.Enter(owner);
inout = UnityEngine.Random.value * 2 > 1;
if (inout)
{
p = GameObject.Instantiate(GameCreaterYoomu.gameObjects["EffectMagicBlastIn"], owner.transform.position, Quaternion.identity);
}
else
{
p = GameObject.Instantiate(GameCreaterYoomu.gameObjects["EffectMagicBlastOut"], owner.transform.position, Quaternion.identity);
}
}
public override void Complete(Creature owner)
{
if (inout)
{
bullet = GameObject.Instantiate(GameCreaterYoomu.gameObjects["BulletMagicBlastIn"], owner.transform.position, Quaternion.identity);
m = bullet.GetComponent<BulletMagicBlast>();
m.damage = (int)(285 * owner.power);
}
else
{
bullet = GameObject.Instantiate(GameCreaterYoomu.gameObjects["BulletMagicBlastOut"], owner.transform.position, Quaternion.identity);
m = bullet.GetComponent<BulletMagicBlast>();
m.damage = (int)(285 * owner.power);
}
}

public override void Execute(Creature owner)
{

}

public override void Exit(Creature owner)
{
base.Exit(owner);
GameObject.Destroy(p);
}
}

/// <summary>
/// 闪避技(穿梭)
/// </summary>
class SkillRestinaDodgeMove : SkillRestina
{
public SkillRestinaDodgeMove()
{
totalCastingTime = 0.4f;
}

public override void Enter(Creature owner)
{
base.Enter(owner);
if (level >= 2)
{
var v = GameObject.Instantiate(GameCreaterYoomu.gameObjects["BulletRoseCreep"], owner.transform.position, Quaternion.identity).GetComponent<BulletRoseCreep>();
Vector2 vf = (GameManager.player.transform.position - owner.transform.position).normalized;
v.target = vf;
v.damage = GameManager.difficulty == Difficulty.Normal ? 75 : 170;
}
}

public override void Complete(Creature owner)
{

}

public override void Execute(Creature owner)
{
owner.transform.position += (Vector3)(7 * owner.moveSpeedRate * Time.deltaTime * owner.face);
}
}

/// <summary>
/// 魅惑视线,对所有看到boss的玩家进入魅惑状态
/// </summary>
class SkillRestinaAttractiveSight : SkillRestina
{
GameObject eff;
public SkillRestinaAttractiveSight()
{
totalCastingTime = 1.2f;
}
public override void Enter(Creature owner)
{
base.Enter(owner);
eff = GameObject.Instantiate(GameCreaterYoomu.gameObjects["EffectAttractiveSight"], owner.transform.position, Quaternion.identity);
}
public override void Complete(Creature owner)
{
if (GameManager.player!=null)
{
Vector2 v = GameManager.player.transform.position - owner.transform.position;
if ((v.x == 0 && v.y == 0) || (GameManager.player.face.normalized - v.normalized).magnitude >= 1.7)
{
if (GameManager.difficulty == Difficulty.Savage)
{
GameManager.player.buffAddSingle(new DebuffAttractedSavage(10, owner, GameManager.player));
}
else
{
GameManager.player.buffAddSingle(new DebuffAttractedNormal(10, owner, GameManager.player));
}
}
}
}

public override void Execute(Creature owner)
{

}
public override void Exit(Creature owner)
{
GameObject.Destroy(eff);
base.Exit(owner);
}
}

/// <summary>
/// 蔓延
/// </summary>
class SkillRestinaRoseCreep : SkillRestina
{
int damage;
public SkillRestinaRoseCreep()
{
totalCastingTime = 0.3f;
damage = GameManager.difficulty == Difficulty.Normal ? 75 : 170;
}
public override void Complete(Creature owner)
{
BulletRoseCreep c = GameObject.Instantiate(GameCreaterYoomu.gameObjects["BulletRoseCreep"], owner.transform.position, Quaternion.identity).GetComponent<BulletRoseCreep>();
c.source = owner;
c.target = owner.face;
c.damage = (int)(damage * owner.power);
}

public override void Execute(Creature owner)
{

}
}

#endregion

让妖梦酱抓狂的澈夕雅——花妖之章4

标签:out   position   释放   change   magic   owa   err   player   rand   

原文地址:http://www.cnblogs.com/yoomuchan/p/6880398.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!