Exemple #1
0
    private void OnPlayerActorCreated(HeroActor actor, bool isFriend)
    {
        m_cameraManager.SetWorldCameraPosition(actor.transform.position);
        m_cameraManager.SetWorldCameraTarget(actor.transform);

        //m_joystick.axisX.directTransform = actor.transform;//todo 这个控制会比较舒服吗?

        m_PlayerActor = actor;
        m_PlayerUnit  = actor.battleEntity;
        var skillIDs = m_PlayerUnit.GetSkillList();

        if (skillIDs == null || skillIDs.Count < 4)
        {
            GameLog.LogError("OnPlayerActorCreated player配置的技能列表少于4个!id : " + m_PlayerUnit.GetID().ToString());
            return;
        }

        var prefab     = (GameObject)UI["MobaSkillItem"];
        var nodeAttack = (RectTransform)UI["NodeAttack"];
        var nodeSkill1 = (RectTransform)UI["NodeSkill1"];
        var nodeSkill2 = (RectTransform)UI["NodeSkill2"];
        var nodeSkill3 = (RectTransform)UI["NodeSkill3"];

        m_MobaSkillItemMap = new Dictionary <AbilityCastType, MobaSkillItem>();
        List <RectTransform> parents = new List <RectTransform> {
            nodeAttack, nodeSkill1, nodeSkill2, nodeSkill3
        };
        List <AbilityCastType> castTypes = new List <AbilityCastType> {
            AbilityCastType.ATTACK, AbilityCastType.SKILL1, AbilityCastType.SKILL2, AbilityCastType.SKILL3
        };

        for (int i = 0; i < 4; i++)
        {
            var castType = castTypes[i];
            var item     = GenerateOne(typeof(MobaSkillItem), prefab, parents[i]) as MobaSkillItem;
            item.Init(castType, m_PlayerUnit.GetAbility(castType), OnFingerDown, OnFingerDrag, OnFingerUp);
            m_MobaSkillItemMap.Add(castType, item);
        }
    }