void OnTriggerEnter2D(Collider2D col) { // If a enemy touch the front line, add this enemy to the gamemanager main list so we can compare shape with it if (col.tag == "FrontLine") { if (vGameManager == null) { vGameManager = GameObject.Find("GameManager2D").GetComponent <GameManager2D>(); } //make this enemy the destroyable vGameManager.vCurEnemy.Add(this); } // If a enemy touch the border, it's game over if (col.tag == "Border") { if (vGameManager == null) { vGameManager = GameObject.Find("GameManager2D").GetComponent <GameManager2D>(); } //game over vGameManager.GameOver(this); } }
public void BuildCastle2D(BuildingInfo info) { GameObject a = Instantiate(preToy) as GameObject; a.GetComponent <SpriteRenderer>().sprite = Data.inst.topList[info.buildingCode]; a.GetComponent <SpriteRenderer>().color = Data.inst.colorList[info.colorCode]; a.transform.GetChild(0).GetComponent <SpriteRenderer>().sprite = Data.inst.backList[info.buildingCode]; a.transform.SetParent(buildingList); a.transform.localPosition = GameManager2D.XYtoVector2(info.x, info.y); a.transform.localScale = Vector3.one * Data.inst.scale; }
//initialise this enemy correctly public void Initialise(GameManager2D vvGameManager) { //get the gamemanager vGameManager = vvGameManager; //add a little factor to be the fastest vSpeed += vGameManager.vScoreValue * 0.05f; //make sure we got a rigidbody attached for moving it. //ONLY the main enemy can move forward. all other pieces doesn't move and make a armor around the enemy if (vRigidBody != null) { vRigidBody.velocity = new Vector2(-vSpeed, 0f); } }
protected override void UpdatePostion() { go += Time.deltaTime * GameManager.ARMY_SPEED * GameManager.inst.gameSpeed; Vector2 pos = Vector2.MoveTowards(fromCity.GetPostion(), toCity.GetPostion(), go); transform.position = GameManager2D.XYtoVector2((int)pos.x, (int)pos.y); /* * distance=Vector3.Distance(transform.position, toCity.transform.position); * if(distance>0.2f) * { * go+=Time.deltaTime*GameManager2D.ARMY_SPEED * GameManager2D.inst.gameSpeed; * transform.position =Vector2.MoveTowards(startPos,endPos,go); * } */ }
public override Vector2 GetPostion() { return(GameManager2D.Vector2ToXY(transform.position)); }