Ejemplo n.º 1
0
    GameObject ArmorMeDaddy(int inVal, Vector3 spawn)
    {
        GameObject enemy = Instantiate(armorViews[inVal].armorPieces[armorViews[inVal].armorPieces.Length - 1].armorPrefab, spawn, Quaternion.identity);

        enemy.layer = LayerMask.NameToLayer("Enemy");

        List <int> numbs       = new List <int>();
        int        numberArmor = Random.Range(0, armorViews[inVal].armorPieces.Length - 3);

        for (int i = 0; i < armorViews[inVal].armorPieces.Length - 2; i++)
        {
            numbs.Add(i);
        }
        for (int i = 0; i < numberArmor; i++)
        {
            int listIndex = Random.Range(0, numbs.Count);
            numbs.RemoveAt(listIndex);
        }
        for (int i = 0; i < numbs.Count; i++)
        {
            GameObject pieceofshitfuckingarmor = Instantiate(armorViews[inVal].armorPieces[numbs[i]].armorPrefab, spawn, Quaternion.identity);
            pieceofshitfuckingarmor.layer = LayerMask.NameToLayer("Armor");
            pieceofshitfuckingarmor.transform.SetParent(enemy.transform);
            pieceofshitfuckingarmor.transform.localPosition = armorViews[inVal].armorPieces[numbs[i]].offset;
        }
        enemy.AddComponent <EnemyMono>();
        enemyMono        = enemy.GetComponent <EnemyMono>();
        enemyMono.target = GameObject.Find("Player");


        return(enemy);
    }
Ejemplo n.º 2
0
        public void Initialize()
        {
            // 默认装备,可以在后续修改其对象
            EnemyMono = Enemy.GameObjectInScene.GetComponent <IEnemyMono>();
            if (EnemyMono != null)
            {
                EnemyMono.EnemyMedi         = this;
                EnemyMono.AnimatorComponent = Enemy.animator;
                EnemyMono.Rgbd   = Enemy.Rgbd;
                EnemyMono.BdTree = Enemy.bt;
                EnemyMono.NavMeshAgentComponent = Enemy.navMeshAgent;
                EnemyWeapon = EnemyMono.iEnemyWeapon;
                EnemyMono.Initialize();
                if (EnemyWeapon != null)
                {
                    EnemyWeapon.EnemyMedi = this;
                    EnemyWeapon.Initialize();
                    EnemyMono.WeaponCollider = EnemyWeapon.WeaponCollider;
                }
                else
                {
                    Debug.LogError("iEnemyWeapon未赋值");
                }
            }

            UpdateEnemyWeapon(EnemyMono.iEnemyWeapon);
        }
Ejemplo n.º 3
0
 // Update is called once per frame
 void Update()
 {
     Collider2D[] colliders = Physics2D.OverlapCircleAll(transform.position, 0.12f);
     for (int i = 0; i < colliders.Length; i++)
     {
         if (colliders[i].gameObject.layer == LayerMask.NameToLayer("Enemy"))
         {
             EnemyMono enemyMono = colliders[i].GetComponent <EnemyMono>();
             enemyMono.KillMePlease();
             healthBar.hp_change(-1);
         }
     }
 }