示例#1
0
    private void Deploy(BattleController.DEPLOY_TYPE type, Slots slots)
    {
        Transform deployment = type == BattleController.DEPLOY_TYPE.LEFT ? DeploymentLeft : DeploymentRight;

        if (null == deployment || null == slots)
        {
            return;
        }

        Transform   child;
        Slot        slot;
        GameObject  go;
        UICharacter characterUIScriptHandler;
        UIHealthBar healthbarUIScriptHandler;

        BattleActionController actionController = BattleActionController.Instance;

        for (int i = 0, count = Mathf.Min(slots.Count, deployment.childCount); i < count; ++i)
        {
            child = deployment.GetChild(i);
            slot  = slots[i];

            if (!slot.IsEmpty)
            {
                go                         = GameObject.Instantiate(Prefab_Character) as GameObject;
                go.name                    = slot.Character.PInfoStats.Name;
                go.transform.parent        = child;
                go.transform.localPosition = Vector3.zero;

                //TODO get UICharacter script to do initialize
                // like sprite.Init( Character character , int deployType );
                characterUIScriptHandler = go.GetComponent <UICharacter>();
                if (null != characterUIScriptHandler)
                {
                    characterUIScriptHandler.Init(slot.Index, slot.Character, type);
                }

                healthbarUIScriptHandler = go.GetComponent <UIHealthBar>();
                if (null != healthbarUIScriptHandler)
                {
                    healthbarUIScriptHandler.init(slot.Character.PPointStats.Health.Max);
                }

                actionController.PlayActionDeployment(go.transform, type);
            }
        }

        StartCoroutine(StartBattle());
    }
示例#2
0
 void Awake( )
 {
     _instance = this;
 }