Beispiel #1
0
        public void Init(GameObject con)
        {
            container = con;

            if (shadowGO)
            {
                shadowGO.SetActive(true);
                return;
            }

            unitVec = new BattleHeroShadowUnit[shadowNum];

            for (int i = 0; i < shadowNum; i++)
            {
                unitVec[i] = new BattleHeroShadowUnit();
            }

            Action <GameObject> loadGameObject = delegate(GameObject _go)
            {
                shadowGO = _go;
                shadowGO.transform.SetParent(container.transform, false);
                mr = _go.GetComponent <MeshRenderer>();
            };

            GameObjectFactory.Instance.GetGameObject("Assets/Arts/battle/BattleTool/Shadow.prefab", loadGameObject, true);
        }
        void Awake()
        {
            unitVec = new BattleHeroShadowUnit[shadowNum];

            for (int i = 0; i < shadowNum; i++)
            {
                unitVec[i] = new BattleHeroShadowUnit();
            }

            mr = gameObject.GetComponent <MeshRenderer>();
        }
 public void GetShadow(GameObject _go, Action <BattleHeroShadowUnit> callBack)
 {
     if (battleHeroShadowScript != null)
     {
         BattleHeroShadowUnit unit = battleHeroShadowScript.GetShadow(_go);
         callBack(unit);
     }
     else
     {
         callList.Add(_go, callBack);
     }
 }
        public BattleHeroShadow()
        {
            Action <GameObject> loadGameObject = delegate(GameObject _go)
            {
                battleHeroShadowScript = _go.GetComponent <BattleHeroShadowScript>();
                if (callList.Count > 0)
                {
                    foreach (GameObject hero in callList.Keys)
                    {
                        Action <BattleHeroShadowUnit> callBack = callList[hero];
                        BattleHeroShadowUnit          unit     = battleHeroShadowScript.GetShadow(hero);
                        callBack(unit);
                    }
                }
            };

            GameObjectFactory.Instance.GetGameObject("Assets/Arts/battle/BattleTool/Shadow.prefab", loadGameObject, true);
        }
 void Update()
 {
     if (mr != null)
     {
         for (int i = 0; i < shadowNum; i++)
         {
             BattleHeroShadowUnit unit = unitVec[i];
             if (unit.State == 1 || unit.IsChange)
             {
                 if (unit.IsChange)
                 {
                     unit.IsChange = false;
                 }
                 mr.material.SetVector("stateInfo" + i.ToString(), unit.GetStateInfoVec());
                 mr.material.SetMatrix("myMatrix" + i.ToString(), unit.GetMatrix());
             }
         }
     }
 }
        public BattleHeroShadowUnit GetShadow(GameObject _go)
        {
            BattleHeroShadowUnit unit = null;

            for (int i = 0; i < shadowNum; i++)
            {
                if (unitVec[i].State == 0)
                {
                    unit = unitVec[i];

                    unit.Init(_go);

                    unit.State = 1;

                    break;
                }
            }

            return(unit);
        }
 public void DelShadow(BattleHeroShadowUnit _unit)
 {
     _unit.Alpha    = 0;
     _unit.State    = 0;
     _unit.IsChange = true;
 }
 public void DelShadow(BattleHeroShadowUnit _unit)
 {
     battleHeroShadowScript.DelShadow(_unit);
 }