Ejemplo n.º 1
0
    public GPlayerChess Spawn(PlayerChessData data)
    {
        GPlayerChess chess = Spawn(data.prototype);

        chess.InitWithSaveData(data);
        return(chess);
    }
Ejemplo n.º 2
0
    public void SwitchToSelected(GPlayerChess chess)
    {
        switch (inputState)
        {
        case InputState.Skill:
            selectedSkill = null;
            selectedChess.CancelSkill();
            selectTask.bPaused = false;
            curTask.Abort();
            curTask = null;
            break;

        case InputState.Selected:
            curTask.Abort();
            curTask = null;
            Select(chess);
            break;

        case InputState.ReadyToSelect:
            Select(chess);
            break;

        default:
            Debug.LogError("ErrorState");
            break;
        }
        ;
        curTask = CreateMoveCommand(chess);
        curTask.CreateFloorHUD(new Color(0, 1, 0, 0.8f));
        curTask.Begin();
        inputState = InputState.Selected;
    }
Ejemplo n.º 3
0
    public async void PerformChessSkill(GPlayerChess chess, PlayerSkill skill, GActor[] inputParams)
    {
        bProcessing = true;
        await chess.PerformSkill(skill, inputParams);

        bProcessing = false;
        eSkillPerformEnd.Invoke();
        SwitchToSelected(chess);
    }
Ejemplo n.º 4
0
    public async void CallChessToMoveAsync(GPlayerChess chess, Vector2Int location)
    {
        bProcessing = true;
        await currentPlayerTurn.BeforeMoveReaction(chess, location);

        await chess.MoveToAsync(location);

        bProcessing = false;
        SwitchToSelected(chess);
    }
Ejemplo n.º 5
0
 public void Bind(GPlayerChess selectedChess)
 {
     this.selectedChess = selectedChess;
     SwitchSkillButton(selectedChess.skills);
     Refresh();
     selectedChess.APAttribute.AddListener(Refresh);
     selectedChess.eSkillChange.AddListener(ReCreateSkillButton);
     PlayerControlManager.instance.eProcessStart.AddListener(Refresh);
     PlayerControlManager.instance.eProcessEnd.AddListener(Refresh);
     aPDisplay.Bind(selectedChess);
 }
Ejemplo n.º 6
0
    //取消选中
    protected void DeSelect()
    {
        if (!selectedChess)
        {
            return;
        }
        var temp = selectedChess;

        selectedChess = null;
        temp.GetComponent <CAgentComponent>().eDeselect.Invoke();
        eDeselect.Invoke();
    }
Ejemplo n.º 7
0
    public GPlayerChess Spawn(GameObject prototype)
    {
        GameObject go = Instantiate(prototype, GridManager.instance.chessContainer);

        go.transform.position = GridManager.instance.GetChessPosition3D(location);
        GPlayerChess chess = go.GetComponent <GPlayerChess>();

        chess.location        = location;
        chess.prefabPrototype = prototype;
        Destroy(gameObject);
        return(chess);
    }
Ejemplo n.º 8
0
    public static RangeTask CreateMoveCommand(GPlayerChess chess)
    {
        Action <GActor[]> t = (o) =>
        {
            instance.CallChessToMoveAsync(chess, o[0].location);
        };
        Func <int, GActor, bool> checker = (index, target) =>
        {
            return(!GridManager.instance.GetChess(target.location));
        };

        return(new RangeTask(chess.navComponent.GetMoveRange, t, 1, checker));
    }
Ejemplo n.º 9
0
 async public UniTask BeforeMoveReaction(GPlayerChess chess, Vector2Int location)
 {
     foreach (GAIChess ai in GridManager.instance.aiChesses)
     {
         if (ai?.bDead == false)
         {
             if (ai.aiCompoment.postSkillReady && ai.postSkill.IsLockAt(chess))
             {
                 await ai.aiCompoment.PostAction();
             }
         }
     }
 }
Ejemplo n.º 10
0
    public async UniTask AssignSkill(GPlayerChess target, PlayerSkill skill, PlayerSkill replaceSkill)
    {
        await Shoot(target.location);

        if (replaceSkill == null)
        {
            target.AddSkill(skill);
        }
        else
        {
            target.ReplaceSkill(skill, replaceSkill);
        }
    }
Ejemplo n.º 11
0
 protected void Select(GChess target)
 {
     if (target == selectedChess)
     {
         return;
     }
     if (selectedChess != null)
     {
         DeSelect();
     }
     selectedChess = target as GPlayerChess;
     selectedChess.GetComponent <CAgentComponent>().eSelect.Invoke();
     eSelectChess.Invoke(selectedChess);
 }
Ejemplo n.º 12
0
    public GChess InstansiateChessAt(GameObject prefab, Vector2Int location)
    {
        var res = Instantiate(prefab, chessContainer);

        res.transform.position = GetChessPosition3D(location);
        GChess chess = res.GetComponent <GChess>();

        chess.location = location;
        if (chess is GPlayerChess)
        {
            GPlayerChess playerChess  = chess as GPlayerChess;
            GameObject   originPrefab = prefab.GetComponent <GPlayerChess>().prefabPrototype;
            if (originPrefab == null)
            {
                originPrefab = prefab;
            }
            playerChess.prefabPrototype = originPrefab;
        }
        AddChess(chess);
        chess.render.GetComponent <Animator>().Play("Birth");
        return(chess);
    }
Ejemplo n.º 13
0
    public async UniTask OpenChestAsync(GChest chest)
    {
        chest.Open();
        int          stage        = 0;
        PlayerSkill  addSkill     = null;
        GPlayerChess target       = null;
        PlayerSkill  replaceSkill = null;

        while (0 <= stage && stage <= 2)
        {
            switch (stage)
            {
            case 0:
                addSkill = await GetSkillAsync(chest.storeSkills);

                if (addSkill == null)
                {
                    stage--;
                }
                else
                {
                    stage++;
                }
                break;

            case 1:
                target = await GetNextClickChessAsync <GPlayerChess>();

                if (target == null)
                {
                    stage--;
                }
                else
                {
                    stage++;
                    if (!target.skillContainFull)
                    {
                        replaceSkill = null;
                        stage++;
                    }
                }
                break;

            case 2:
                replaceSkill = await GetSkillAsync(target.skills);

                if (target == null)
                {
                    stage--;
                }
                else
                {
                    stage++;
                }
                break;
            }
        }
        if (stage == -1)
        {
            chest.Close();
        }
        else if (stage == 3)
        {
            await chest.AssignSkill(addSkill, target, replaceSkill);

            chest.Close();
        }
    }
Ejemplo n.º 14
0
 async public UniTask AssignSkill(PlayerSkill skill, GPlayerChess target, PlayerSkill replaceSkill)
 {
     await chestSkill.AssignSkill(target, skill, replaceSkill);
 }
Ejemplo n.º 15
0
    async public override UniTask ProcessAsync(GActor[] inputParams)
    {
        GPlayerChess target = inputParams[0] as GPlayerChess;

        target.AddSkill(addSKill);
    }
Ejemplo n.º 16
0
 public void UnBind()
 {
     selectedChess.APAttribute.RemoveListener(Refresh);
     selectedChess = null;
 }
Ejemplo n.º 17
0
 public void Bind(GPlayerChess selectedChess)
 {
     this.selectedChess = selectedChess;
     selectedChess.APAttribute.AddListener(Refresh);
     Refresh();
 }