コード例 #1
0
ファイル: DarkPrince.cs プロジェクト: chanyowthea/Beacon
    public override void Init(ERole roleIdent, Pos pos, Sprite[] moveSprites)
    {
        IDie die = new NormalDie();

        die.onDie = () =>
        {
            Player._Instance.isLockMove = true;
            PlotManager.instance.Die_DarkPrince(() =>
            {
                GameData._isLockDoor = false;
                if (GameData._isGrandDaughterInQueue)
                {
                    GameData._CanRotateCamera = false;
                    UIManager._Instance.SetMaskEnable(false);
                }

                PlotManager.instance.BattleAfter(() =>
                {
                    // 此处有问题,应该是在上面显示,但是由于这个栈里面下面有一句也是弹出SystemMessage,因此把这个顶掉了
                    _getKeyRoutine = GetKeyRoutine(GameData._isGrandDaughterInQueue ? (HUDView._maxSysMsgTime * 2) : (HUDView._maxSysMsgTime));
                    CoroutineUtil.Start(_getKeyRoutine);
                    Player._Instance.isLockMove = false;

                    // 从NPC表中移除NPC
                    Singleton._npcManager.RemoveNPC(ERole.DarkPrince);
                });
            });
        };
        _iHP.Init(die, transform, 5);
        var move = (AIMove)_iMove;

        move.onMove = (Pos dirPos) =>
        {
            // 黑王子移动的时候也要提示
            if (!GameData._isGrandDaughterInQueue && !GameData._isGrandDaughterRebel)
            {
                MoveUtil.ShowDangerTip(Player._Instance.GetPos());
            }
        };
        move.onAllure = () =>
        {
            Allure(Singleton._npcManager.GetNPC <GrandDaughter>(ERole.GrandDaughter));
        };
        _iMove.Init(pos, transform);
        move._followTarget = Player._Instance.transform;
        base.Init(roleIdent, pos, moveSprites);
    }
コード例 #2
0
ファイル: PlayerMove.cs プロジェクト: chanyowthea/Beacon
    protected override void Move(int x, int y)     // 3 Enemy, 2 Pit, 1 Wall, 0 Road,
    {
        int originX  = _x;
        int originY  = _y;
        int newX     = _x + (int)x;
        int newY     = _y + (int)y;
        int curIndex = MapManager.CurIndex(newX, newY);

//		Debug.LogError("Move curIndex: " + curIndex);
        if (curIndex >= 0)
        {
            //			Debug.Log("curIndex: " + curIndex + ", curMap: " + MapManager._curMap[curIndex]);
            if (MapManager._curMap[curIndex] == MapCode.NONE || MapManager._curMap[curIndex] == MapCode.BEFORE_UPSTAIR ||
                MapManager._curMap[curIndex] == MapCode.BEFORE_DOWNSTAIR)
            {
                //如果人物移动,那么播放音效
                Singleton._audioManager.Walk();

                //				int index = MapManager.CurIndex(_x, _y);
                _x = newX;
                _y = newY;
                ChangeStep(GameData._Step + 1);
                CalculateDirection();

                if (PlotManager.status == EPlotStatus.Battle && !GameData._isGrandDaughterInQueue && !GameData._isGrandDaughterRebel)
                {
                    MoveUtil.ShowDangerTip(new Pos(newX, newY));
                }

                int enemyX;
                int enemyY;
                // 检测周围的八个点
                if (MapManager.IsExistCodeInRange(newX, newY, out enemyX, out enemyY, MapCode.NPC_GRAND_DAUGHTER) ||
                    MapManager.IsExistCodeInRange(newX, newY, out enemyX, out enemyY, MapCode.NPC_DARK_PRINCE))
                {
                    int idx = MapManager.CurIndex(enemyX, enemyY);
                    if (
//						GameData._curMeetHint <= 0 &&
                        MapManager._curMap[idx] == MapCode.NPC_GRAND_DAUGHTER)
                    {
                        if (PlotManager.status == EPlotStatus.Start)
                        {
                            GameObject go  = MapManager.GetObj(idx);
                            NPC        npc = null;
                            if (go != null)
                            {
                                npc = go.GetComponent <NPC>();
                            }
                            if (npc != null && npc._roleIdent == ERole.GrandDaughter)
                            {
                                if (GameData._curMeetHint == 0)
                                {
                                    UIManager._Instance.SetSysMsgInfo(SystemMessage._meetHint_Find);
                                }
                                else
                                {
                                    UIManager._Instance.SetSysMsgInfo(SystemMessage._meet_Find);
                                }
                                GameData._curMeetHint = 1;

                                // start plot
                                isLockMove = true;
                                PlotManager.instance.Meet(npc._roleIdent, () =>
                                {
                                    isLockMove = false;
                                });
                            }
                        }
                        else if (PlotManager.status == EPlotStatus.Battle)
                        {
                            GameObject go  = MapManager.GetObj(idx);
                            NPC        npc = null;
                            if (go != null)
                            {
                                npc = go.GetComponent <NPC>();
                            }
                            // 如果是孙女
                            if (npc != null && npc._roleIdent == ERole.GrandDaughter)
                            {
                                int            dis;
                                EFaceDirection face;
                                bool           rs = MoveUtil.GetFaceDirection(out dis, out face, GetPos(), MapCode.NPC_GRAND_DAUGHTER,
                                                                              (int)(Camera.main.transform.eulerAngles.z / 90));
                                if (rs && (int)face <= (int)EFaceDirection.Right)
                                {
                                    string label = "";
                                    switch (face)
                                    {
                                    case EFaceDirection.Forward:
                                        label = "前";
                                        break;

                                    case EFaceDirection.Backward:
                                        label = "后";
                                        break;

                                    case EFaceDirection.Left:
                                        label = "左";
                                        break;

                                    case EFaceDirection.Right:
                                        label = "右";
                                        break;
                                    }
                                    UIManager._Instance.SetTipInfo(string.Format(TipMessage._grandDaughterNear, label));
                                }
                            }
                        }
                    }
                    else if (MapManager._curMap[idx] == MapCode.NPC_DARK_PRINCE)
                    {
                        // 开始剧情
                        // 孙女加入与否都可以见到黑王子
                        if (PlotManager.status == EPlotStatus.Battle_Before)
                        {
                            GameObject go  = MapManager.GetObj(idx);
                            NPC        npc = null;
                            if (go != null)
                            {
                                npc = go.GetComponent <NPC>();
                            }
                            if (npc != null && npc._roleIdent == ERole.DarkPrince)
                            {
                                isLockMove = true;
                                npc.GetComponent <DarkPrince>()._startMove = true;
                                PlotManager.instance.Battle(() =>
                                {
                                    isLockMove = false;
                                });
                            }
                        }
                    }
                }
            }
            else
            {
                // 下面都是未移动
                if (MapManager._curMap[curIndex] == MapCode.ENEMY)
                {
                    Singleton._audioManager.Attack();
                    // do hurt
                    GameObject go = MapManager.GetObj(curIndex);
                    if (go != null)
                    {
                        Enemy enemy = go.GetComponent <Enemy>();
                        int   count = 1;
                        enemy.Hurt(count);
                        // TODO 要设置敌人的攻击力,玩家的防御力
                        UIManager._Instance.SetSysMsgInfo(string.Format(SystemMessage._attack, "敌人", count));
                    }
                }
                else if (MapManager._curMap[curIndex] == MapCode.PIT)
                {
                    Singleton._audioManager.Attack();
                    int count = 1;
                    if (onMinusHP != null)
                    {
                        onMinusHP(count);
                    }
                    UIManager._Instance.SetSysMsgInfo(string.Format(SystemMessage._hurt, count));
                }
                // 如果将要移动的地方已经有孙女在那个位置,那么对那个位置的目标造成伤害
                else if (MapManager._curMap[curIndex] == MapCode.NPC_GRAND_DAUGHTER)
                {
                    Singleton._audioManager.Attack();
                    GameObject go = MapManager.GetObj(curIndex);
                    if (go != null)
                    {
                        GrandDaughter grandDaughter = go.GetComponent <GrandDaughter>();
                        int           count         = 1;
                        grandDaughter.Hurt(count);
                        // TODO 要设置敌人的攻击力,玩家的防御力
                        UIManager._Instance.SetSysMsgInfo(string.Format(SystemMessage._attack, GameData._Instance._roleLib.GetRole(ERole.GrandDaughter)._name, count));
                    }
                }
                else if (MapManager._curMap[curIndex] == MapCode.NPC_DARK_PRINCE)
                {
                    // 由于这个时候,孙女离开队伍,爷爷一个人会迷失方向,只能攻击前面的对象
                    if (MoveUtil.IsExistCodeFront(new Pos(originX, originY), MapCode.NPC_DARK_PRINCE))
                    {
                        Singleton._audioManager.Attack();
                        // do hurt
                        GameObject tempObj = MapManager.GetObj(curIndex);
                        if (tempObj != null)
                        {
                            DarkPrince price = tempObj.GetComponent <DarkPrince>();
                            int        count = 1;
                            price.Hurt(count);
                            // TODO 要设置敌人的攻击力,玩家的防御力
                            UIManager._Instance.SetSysMsgInfo(string.Format(SystemMessage._attack, GameData._Instance._roleLib.GetRole(ERole.DarkPrince)._name, count));
                        }
                    }
                    else
                    {
                        Singleton._audioManager.CannotMove();
                        CalculateDirection(false);
                    }
                }
                else                 // 不是可移动区域并且没有进行攻击
                {
                    Singleton._audioManager.CannotMove();
                    CalculateDirection(false);                     // 切换下一关不要显示tip
                }
            }
        }

        // 如果将要移动的区域超出边界,那么判定在边缘,可以切换地图,
        // 这样不好,如果传送门在地图中间或者边缘为空并不是地图,那么就会出BUG
        else
        {
            if (GameData._isLockDoor)
            {
                Singleton._audioManager.CannotMove();
                UIManager._Instance.SetTipInfo(Tip._lockDoor);
                return;
            }
            CalculateDirection();             // 为什么这里要Calc?当无法切换关卡时的处理,不应该这样
//			Debug.LogError("curLevel: " + GameData._CurLevel + ", code: " + MapManager._curMap[MapManager.CurIndex(_x, _y)]);
            Singleton._levelManager.NextLevel(GameData._CurLevel + (MapManager._curMap[MapManager.CurIndex(_x, _y)] == '9' ? 1 : -1));
        }
    }