void OnDrawGizmosSelected() { if (NPC_Type == NPC_STATE.BOSS_NPC || NPC_Type == NPC_STATE.ZAI_TI_NPC) { } else if (NPC_Type != NPC_STATE.ZAI_TI_NPC) { NPC_Type = NPC_STATE.ZAI_TI_NPC; } }
// Use this for initialization void Awake() { if (NPC_Type == NPC_STATE.BOSS_NPC || NPC_Type == NPC_STATE.ZAI_TI_NPC) { } else { NPC_Type = NPC_STATE.ZAI_TI_NPC; } ZaiTiNpcTran = transform; ChuanTran = ZaiTiNpcTran.parent; //LocalPosOffset = Vector3.Scale(ZaiTiNpcTran.localPosition, ChuanTran.localScale); //LocalPosOffset = ZaiTiNpcTran.localPosition; //ZaiTiNpcTran.parent = GameCtrlXK.MissionCleanup; WaterwheelPlayer = WaterwheelPlayerCtrl.GetInstance().transform; AnimatorNpc = GetComponent <Animator>(); if (BuWaWaObj != null) { BuWaWaObj.SetActive(false); Rigidbody rigObj = BuWaWaObj.GetComponent <Rigidbody> (); if (rigObj == null) { rigObj.name = "null"; } } NpcMoveScript = ZaiTiNpcTran.parent.GetComponent <NpcMoveCtrl>(); if (!IsDiLeiNpc) { RandomDoRootAction(); } else if (!NpcMoveScript.IsDanCheLvNpc) { IsDoFireAction = true; } BuWaWaPowerVal = NpcMoveScript.BuWaWaPowerVal; IsTeShuZiDanHaiDao = NpcMoveScript.IsTeShuZiDanHaiDao; /*if (IsTeShuZiDanHaiDao) { * NpcSimpleBulletObj.SetActive(false); * }*/ ResetActionInfo(); }
public bool Update() { if (Vec2.Approximately(position, targetposition)) { if (rand.NextDouble() <= 0.5) { targetposition = GetRandPosFromArea(new Vec2(10, 10), new Vec2(2600, 330)); return(true); } else { state = NPC_STATE.STOP; stopfor = (rand.NextDouble() + 1.0) * 30; } } else { switch (state) { case NPC_STATE.STOP: timer++; if (timer >= stopfor) { state = NPC_STATE.MOVE; timer = 0; stopfor = 0; } break; case NPC_STATE.MOVE: Vec2 diff = targetposition - position; diff = Vec2.Normalize(diff); diff *= speed; position += diff; collision.setPosition(position); break; case NPC_STATE.BATTLE: break; } } return(false); }
public Npc(Item hat, int level, Vec2 position, bool hostile, double id, string areaname) { this.id = id; rand = MyRandom.rand; this.position = position; this.targetposition = position; droplist = new List <Item>(); this.stats = new Stats(hat, level); this.appearance = hat.baseitem.appearance; droplist.Add(hat); this.level = level; this.hostile = hostile; this.speed = 4; this.collision = new CollisionCircle(position, 50, this, CollisionCircle.ObjectType.NPC); state = NPC_STATE.STOP; timer = 0; stopfor = 40; this.areaname = areaname; }