コード例 #1
0
        private void SendAllMoveUnit(uint userId, Unit unit, Battle battle, List <GameAction> actions)
        {
            BattleData data = battle.GetData();

            for (int i = 0; i < data.users.Count; i++)
            {
                List <GameAction> list = new List <GameAction>();
                if (data.users[i].userid == userId)
                {
                    list.AddRange(actions);
                }
                else
                {
                    bool isVisible = false;
                    User user      = d.GetUser(data.users[i].userid);
                    Unit unitEnemy = user.GetSelectUnit();
                    for (int j = 0; j < actions.Count; j++)
                    {
                        if (VisiblePoint.IsVisible(unitEnemy.pos, actions[i].GetPos(), battle.GetMap(), GameData.blockInfo))
                        {
                            if (!isVisible)
                            {
                                list.Add(new GameActionVisible(unit, true));
                                isVisible = true;
                            }
                        }
                    }
                }
                Data.t.netMsg.Add(new MsgServerGameActionList(data.users[i].userid, list));
            }
        }
コード例 #2
0
        public void UnitRotate(uint userId, int dir)
        {
            User   user   = d.GetUser(userId);
            Unit   unit   = user.GetSelectUnit();
            Battle battle = d.GetBattle(user.battleId);

            if (!battle.IsUserTurn(userId))
            {
                return;
            }
            int ap = GameUtil.CalcDir(unit.dir, dir) * GameData.unitInfo[unit.id].apRotate;

            if (unit.ap < ap)
            {
                return;
            }
            unit.ap -= ap;
            unit.dir = dir;
            BattleData data = battle.GetData();

            for (int i = 0; i < data.users.Count; i++)
            {
                Vector2w pos = d.GetBattleUnitPos(data.users[i].userid);
                if (data.users[i].userid == userId || VisiblePoint.IsVisible(unit.pos, pos, battle.GetMap(), GameData.blockInfo))
                {
                    Data.t.netMsg.Add(new MsgServerGameAction(data.users[i].userid, new GameActionRotateUnit(unit.uid, unit.dir, unit.pos)));
                    Data.t.netMsg.Add(new MsgServerGameAction(data.users[i].userid, new GameActionInfoUnit(unit)));
                }
            }
        }
コード例 #3
0
        private bool IsNewUnitVisible(UnitVisible unitVisible, uint userId, Vector2w pos, Battle battle)
        {
            var data = battle.GetData();

            for (int i = 0; i < data.users.Count; i++)
            {
                if (data.users[i].userid != userId)
                {
                    Vector2w unitPos = d.GetBattleUnitPos(userId);
                    if (VisiblePoint.IsVisible(pos, unitPos, battle.GetMap(), GameData.blockInfo) && !unitVisible.IsVisible(data.users[i].userid))
                    {
                        return(true);
                    }
                }
            }
            return(false);
        }