Esempio n. 1
0
        public void OnAgentPushBox(BattlePlayerController bp, MapGenerator mapGenerator)
        {
            this.mapGenerator = mapGenerator;

            ExploreManager em = mapGenerator.GetComponent <ExploreManager> ();

            em.DisableInteractivity();

            int[,] mapWalkableInfo = mapGenerator.mapWalkableInfoArray;

            int playerPosX = Mathf.RoundToInt(bp.transform.position.x);
            int playerPosY = Mathf.RoundToInt(bp.transform.position.y);

            int boxPosX = Mathf.RoundToInt(this.transform.position.x);
            int boxPosY = Mathf.RoundToInt(this.transform.position.y);


            if (playerPosX < boxPosX && CanMoveTo(boxPosX + 1, boxPosY))
            {
                this.transform.DOMove(new Vector3(boxPosX + 1, boxPosY), 1.0f).OnComplete(delegate {
                    mapWalkableInfo[boxPosX, boxPosY]     = 1;
                    mapWalkableInfo[boxPosX + 1, boxPosY] = 0;
                    em.EnableInteractivity();
                });
            }
            else if (playerPosX > boxPosX && CanMoveTo(boxPosX - 1, boxPosY))
            {
                this.transform.DOMove(new Vector3(boxPosX - 1, boxPosY), 1.0f).OnComplete(delegate {
                    mapWalkableInfo[boxPosX, boxPosY]     = 1;
                    mapWalkableInfo[boxPosX - 1, boxPosY] = 0;
                    em.EnableInteractivity();
                });
            }
            else if (playerPosY < boxPosY && CanMoveTo(boxPosX, boxPosY + 1))
            {
                this.transform.DOMove(new Vector3(boxPosX, boxPosY + 1), 1.0f).OnComplete(delegate {
                    mapWalkableInfo[boxPosX, boxPosY]     = 1;
                    mapWalkableInfo[boxPosX, boxPosY + 1] = 0;
                    em.EnableInteractivity();
                });
            }
            else if (playerPosY > boxPosY && CanMoveTo(boxPosX, boxPosY - 1))
            {
                this.transform.DOMove(new Vector3(boxPosX, boxPosY - 1), 1.0f).OnComplete(delegate {
                    mapWalkableInfo[boxPosX, boxPosY]     = 1;
                    mapWalkableInfo[boxPosX, boxPosY - 1] = 0;
                    em.EnableInteractivity();
                });
            }

            em.EnableInteractivity();
        }
        /// <summary>
        /// 玩家死亡
        /// </summary>
        override public void AgentDie()
        {
            if (agent.isDead)
            {
                return;
            }

            agent.isDead = true;

            StopCoroutinesWhenFightEnd();

            // 如果是在战斗中死亡的
            if (bmCtr != null)
            {
                bmCtr.StopCoroutinesWhenFightEnd();

                ActiveBattlePlayer(false, false, true);

                ExploreManager em = exploreManager.GetComponent <ExploreManager> ();

                em.DisableInteractivity();

                PlayRoleAnim("die", 1, () => {
                    em.BattlePlayerLose();
                });

                return;
            }

            // 如果不是在战斗中死亡的
            PlayRoleAnim("die", 1, () => {
                agent.ResetBattleAgentProperties(true);

                exploreManager.GetComponent <ExploreManager>().QuitExploreScene(false);
            });
        }