Example #1
0
    public void CreateSoldier()
    {
        GameObject FlagZombie = Resources.Load("Prefabs/FlagZombie", typeof(GameObject)) as GameObject;

        for (int i = 0; i < 1; i++)
        {
            var basePostion = LeftPlayer.transform.GetChild(0).position;
            var random      = Random.insideUnitCircle * 5;
            basePostion += new Vector3(Mathf.Abs(random.x), random.y);
            var soldier = Instantiate(FlagZombie, basePostion, new Quaternion(0f, 1f, -0.3f, 0), LeftPlayer.transform.GetChild(1).transform);
            soldier.GetComponent <SoldierManager>().Init(XMLTools.GetSoldierByType(SoldierType.FlagZombie));
            soldier.name = SoldierType.FlagZombie + "---" + Time.time;
            soldier      = Instantiate(FlagZombie, basePostion, new Quaternion(0f, 1f, -0.3f, 0), LeftPlayer.transform.GetChild(1).transform);
            soldier.GetComponent <SoldierManager>().Init(XMLTools.GetSoldierByType(SoldierType.CabbageZombie));
            soldier.name = SoldierType.FlagZombie + "---" + Time.time;
        }
        for (int i = 0; i < 1; i++)
        {
            var basePostion = RightPlayer.transform.GetChild(0).position;
            var random      = Random.insideUnitCircle * 5;
            basePostion += new Vector3(-Mathf.Abs(random.x), random.y);
            var soldier = Instantiate(FlagZombie, basePostion, new Quaternion(0.3f, 0f, 0f, 1f), RightPlayer.transform.GetChild(1).transform);
            soldier.GetComponent <SoldierManager>().Init(XMLTools.GetSoldierByType(SoldierType.FlagZombie));
            soldier.name = SoldierType.FlagZombie + "---" + Time.time;
            soldier      = Instantiate(FlagZombie, basePostion, new Quaternion(0.3f, 0f, 0f, 1f), RightPlayer.transform.GetChild(1).transform);
            soldier.GetComponent <SoldierManager>().Init(XMLTools.GetSoldierByType(SoldierType.CabbageZombie));
            soldier.name = SoldierType.FlagZombie + "---" + Time.time;
        }
    }
Example #2
0
 void Start()
 {
     GetComponent <Rigidbody>().velocity = new Vector3();
     startTime    = Time.time;
     startPostion = transform.position;
     if (name.Equals("Home"))
     {
         Init(XMLTools.GetSoldierByType(SoldierType.Home));
         if (playerType == PlayerType.Left)
         {
             GameManager.Instance.LeftHome = soldier;
         }
         else
         {
             GameManager.Instance.RightHome = soldier;
         }
         StartCoroutine(CloseAttack());
         StartCoroutine(RemoteAttack());
         return;
     }
     StartCoroutine(CloseAttack());
     StartCoroutine(RemoteAttack());
     playerType = (PlayerType)Enum.Parse(typeof(PlayerType), transform.parent.name);
 }