예제 #1
0
 // 共同的定义
 private void InitCharManager()
 {
     // runningData需要深拷贝
     this.runningData = Math.DeepCopyByBinary <CharcterData>(this.originalData);
     // 获取攻击范围组件
     range = gameObject.GetComponentInChildren <RangeRunning>();
     // 绑定范围敌人数组
     enemies = range.enemies;
     // 血条组件已经初始化,可以直接调用
     SetHpSilder(runningData.attributes.nowHp / originalData.attributes.maxHp, true);
     foreach (Transform child in perfab.GetComponentsInChildren <Transform>(true))
     {
         if (child.gameObject.name == "FirePosition")
         {
             firePosition = child.gameObject.transform;
         }
         else if (child.gameObject.name == "Head")
         {
             head = child.gameObject.transform;
         }
         else if (child.gameObject.name == "Bullet1")
         {
             child.gameObject.SetActive(false);
         }
         else if (child.gameObject.name == "Bullet2")
         {
             bulletPrefab = child.gameObject;
             bulletPrefab.SetActive(false);
         }
         else if (child.gameObject.name == "Laser")
         {
             laserPerfab = child.gameObject;
             laserPerfab.SetActive(false);
         }/*
           * else if (child.gameObject.name == "Collider")
           * {
           * if(originalData.isEnemy)
           * child.gameObject.GetComponent<Rigidbody>().constraints =
           * RigidbodyConstraints.FreezePositionX | RigidbodyConstraints.FreezePositionY | RigidbodyConstraints.FreezePositionZ;
           * else
           * child.gameObject.GetComponent<Rigidbody>().constraints =
           * RigidbodyConstraints.FreezePositionZ;
           * }*/
     }
 }
예제 #2
0
 void InitLaser(Object[] obj)
 {
     firePosition = (Transform)obj[0];
     target       = (GameObject)obj[1];
     range        = (RangeRunning)obj[2];
 }