예제 #1
0
    void spawnAI(int num)
    {
        float x, z, max_z;

        Random.InitState((int)Time.time);

        for (int i = 0; i < num; i++)
        {
            // 随机选择出生地点
            do
            {
                x     = Random.Range(-15f, 15f);
                max_z = Mathf.Sqrt(225f - x * x);
                z     = Random.Range(-max_z, max_z);
            } while (Mathf.Abs(x) < 4F || Mathf.Abs(z) < 4F);

            // 随机选择一种类型
            GameObject   AIPrefab = Random.value < 0.5 ? AI_MagicianPrefab : AI_PriestPrefab;
            GameObject   AI       = Instantiate(AIPrefab, new Vector3(x, 0, z), new Quaternion(0, 0, 0, 0));
            WizardCommon wizard   = AI.GetComponent <WizardCommon>();
            // 根据当前波数来提升AI的战斗力
            wizard.initialAttack += wave;
            wizard.initialHP     += wave * 2;
        }
    }
예제 #2
0
 private void OnTriggerEnter(Collider other)
 {
     if (other.tag == "Player")
     {
         WizardCommon wizardcommon = other.gameObject.GetComponent <WizardCommon>();
         wizardcommon.speed        += 3;
         wizardcommon.speedBuffTime = 500;
         Destroy(this.gameObject);
     }
 }
예제 #3
0
    private void OnTriggerEnter(Collider other)
    {
        if (other.tag == "Player")
        {
            WizardCommon player = other.gameObject.GetComponent <WizardCommon>();
            player.attack        += 5;
            player.attackBuffTime = 500;
            //GameObject[] AI_list = GameObject.FindGameObjectsWithTag("AI");
            //for(int i = 0; i < AI_list.Length; i++)
            //{
            //    AIWC = AI_list[i].GetComponent<WizardCommon>();
            // AIWC.getDmg += 5;
            //    AIWC.attackBuffTime = 500;
            //}

            Destroy(this.gameObject);
        }
    }
예제 #4
0
 private void OnTriggerEnter(Collider other)
 {
     if (other.tag == "Player")
     {
         WizardCommon player = other.gameObject.GetComponent <WizardCommon>();
         if (player.HP < player.initialHP)
         {
             if (player.HP + 5 < player.initialHP)
             {
                 player.HP = player.HP + 5;
             }
             else
             {
                 player.HP = player.initialHP;
             }
             Destroy(this.gameObject);
         }
     }
 }
예제 #5
0
 void Start()
 {
     wizardCommon = GetComponent <WizardCommon> ();
     game         = GameObject.FindWithTag("GameController").GetComponent <Game>();
     scoreUI      = game.scoreUI;
 }