// Use this for initialization void Start() { speed = gameObject.GetComponent <Enemy>().speed; pathToFollow = GameObject.Find(pathname).GetComponent <MovingPath>(); last_pos = transform.position; CurrentWaypoint = 1; }
public Enemy(int x, int y) { bornX = x; bornY = y; Object enemyPrefab = Resources.Load("enemy"); Assert.IsNotNull(enemyPrefab); Vector3 pos = new Vector3((float)GameUtil.ToWorldUnit(x), (float)GameUtil.ToWorldUnit(y), 0.0f); enemy = (GameObject)GameObject.Instantiate(enemyPrefab, pos, Quaternion.identity); movingPath = new MovingPath(); }
public override void KillSelf() { if (Destroyed) { return; } var chunk = ChunkManager.GetChunkByNum(ChunkNumber); chunk.SetIndex(CurrentPos, -1); chunk.RemoveObject(CurrentPos); if (pickUped != null) { ItemEvents.OnDeathDropItem(pickUped, this); } ClickManager.RemoveChosing(gameObject); GameMoveManager.CancelAllOrders(this); if (GroupUtil.isCreatureGroup(Group)) { GameOrderManager.RemoveMarks(this); //SimpleOrderManager.CancelOrders(this); if (MovingPath != null) { MovingPath.Clear(); } } if (SecondaryGroundLvL.isSecondaryGroup(Group)) { SecondaryGroundLvL.RemovePos(ChunkNumber, CurrentPos); } if (FlagManager.IsFlagAtPos(CurrentPos)) { FlagManager.RemoveFlag(CurrentPos); } ProgressUnitBar.RemoveProgressBar(this); CreatureGroupManager.RemoveEntFromGroup(this); BuildingsGroupManager.RemoveBuildingFromGroup(this); RemoveAbilities(); if (research != null) { var sameBuilds = BuildingsGroupManager.GetAllInChunkWithName(ChunkNumber, OriginalName); if (sameBuilds.Count == 0) { Owner.RemoveResearch(research); } } Coloring.RecolorObject(ChunkUtil.GetDovvner(CurrentPos)); Owner.foodCount -= foodCost; Owner.foodMax -= foodGive; if (gameObject != null) { Destroy(gameObject); } Destroyed = true; }
void Start() { movingPath = new MovingPath(); }