Example #1
0
    private void CreateUnitGo(Unit _unit)
    {
        UnitSDS sds = _unit.sds as UnitSDS;

        GameObject go = GameObjectFactory.Instance.GetGameObject(sds.model, null);

        go.transform.SetParent(unitContainer, false);

        PublicTools.SetLayer(go, unitContainer.gameObject.layer);

//		if(_unit.isMine == battle.clientIsMine){
//
//			go.GetComponent<Renderer> ().material.SetColor ("_Color", Color.blue);
//
//		}else{
//
//			go.GetComponent<Renderer> ().material.SetColor ("_Color", Color.yellow);
//		}

        HeroStateMachine2 hm = go.GetComponent <HeroStateMachine2> ();

        hm.Init(_unit, this);

        unitGoDic.Add(_unit.uid, hm);

        unitGoList.AddLast(_unit.uid);
    }
Example #2
0
    private void RemoveUnitGo(int _uid)
    {
        HeroStateMachine2 hm = unitGoDic [_uid];

        unitGoDic.Remove(_uid);

        GameObject.Destroy(hm.gameObject);
    }
Example #3
0
    private void RefreshUnit(Dictionary <int, LinkedList <int> > _clientAttackData)
    {
        Dictionary <int, Unit> .Enumerator enumerator = battle.unitDic.GetEnumerator();

        while (enumerator.MoveNext())
        {
            int uid = enumerator.Current.Key;

            Unit unit = enumerator.Current.Value;

            if (!unitGoDic.ContainsKey(uid))
            {
                CreateUnitGo(unit);
            }
        }

        Dictionary <int, Unit> .KeyCollection.Enumerator enumerator2 = battle.unitDic.Keys.GetEnumerator();

        while (enumerator2.MoveNext())
        {
            unitGoDic [enumerator2.Current].UpdateAction(_clientAttackData);
        }

        LinkedListNode <int> node = unitGoList.First;

        while (node != null)
        {
            LinkedListNode <int> nextNode = node.Next;

            int uid = node.Value;

            if (!battle.unitDic.ContainsKey(uid))
            {
                HeroStateMachine2 hm = unitGoDic [uid];

                if (hm.damageTimes == 0 && !hm.isAttacking)
                {
                    RemoveUnitGo(uid);

                    unitGoList.Remove(node);
                }
            }

            node = nextNode;
        }
    }
Example #4
0
    public void UpdateAction(Dictionary <int, LinkedList <int> > _attackData)
    {
        SetPos(battleManager.GetUnitPos(hero));

        if (_attackData != null && _attackData.ContainsKey(hero.uid))
        {
            DoAttackCommand();

            damageList = _attackData [hero.uid];

            LinkedList <int> .Enumerator enumerator = damageList.GetEnumerator();

            while (enumerator.MoveNext())
            {
                HeroStateMachine2 hm = battleManager.unitGoDic [enumerator.Current];

                hm.damageTimes++;

                if (!isAttacking)
                {
                    isAttacking = true;

                    Attack(hm.transform.localPosition.x, hm.transform.localPosition.z);
                }
            }
        }
        else if (hero.targetUid == -1 && !isAttacking)
        {
            if (hero.prefVelocity != RVO.Vector2.zero)
            {
                float posFix = battleManager.battle.clientIsMine ? 1 : -1;

                Move((float)hero.prefVelocity.x * posFix, (float)hero.prefVelocity.y * posFix);
            }
        }
    }