コード例 #1
0
        public void RoundStartFun(int unitId)
        {
            Debug.Log("RPC_RoundStart");
            TimeFrozen  = false;
            _roundStart = Time.time;
            var foundUnit = ApplicationModel.MatchModel.Units.First(u => u.Id == unitId);

            if (!PhotonHelper.PlayerIsSinglePlayer())
            {
                MatchController.SetCurrentUnit(foundUnit);
            }
            if (foundUnit.Color == GetCurrentPlayerColor() && GetCurrentPlayer().Name == PhotonNetwork.NickName)
            {
                foundUnit.SetAllowControll(true);
                foundUnit.SetScopeVisibility(true);
            }
            else
            {
                foundUnit.SetAllowControll(false);
                foundUnit.SetScopeVisibility(false);
            }

            CameraService.SetCameraFollowAndRotationTarget(foundUnit.gameObject.transform);

            CurrentWeaponController.ResetPower();
            CurrentWeaponController.SetCurrentWeapon(ShootService.GetNoneWeapon());

            if (RoundChangedEvent != null)
            {
                RoundChangedEvent.Invoke(this, new EventArgs());
            }
            EndMatchIfNeeded();
        }
コード例 #2
0
        private void RoundEnd()
        {
            var unit = MatchController.GetCurrenUnit();

            if (unit != null)
            {
                unit.SetAllowControll(false);
                unit.SetScopeVisibility(false);
            }
            TimeFrozen = true;
            CurrentWeaponController.SetCurrentWeapon(ShootService.GetNoneWeapon());
            EndMatchIfNeeded();
        }
コード例 #3
0
ファイル: MyStrategy.cs プロジェクト: Illedan/RAIC2019
    public UnitAction GetAction(Unit unit, Game game, AiCup2019.Debug debug)
    {
        if (m_lastTick >= game.CurrentTick) // Verify this number
        {
            //TODO: Check number of bullets
            LogService.WriteLine("Cached choice");
            return(CreateAction(m_lastGame.Units.First(u => u.unit.Id == unit.Id), m_lastGame));
        }

        Const.Reset(game.Properties, game);
        Debug = debug;
        var myGame = new MyGame(game, unit);
        var sim    = m_lastGame = new SimGame(myGame, unit);

        m_lastTick = game.CurrentTick;
        DistService.CalcDists(sim);
        ShootService.Initialize(sim);
        foreach (var b in sim.Bullets)
        {
            b.CalcCollisionTime(sim);
        }

        foreach (var u in sim.Units)
        {
            u.WalkTarget = WalkService.FindWalkTarget(sim, u);
            u.AimTarget  = AimService.GetAimTarget(sim, u);
            u.Shoot      = ShootService.ShouldShoot(sim, u);
            if (u.Player.Id == unit.PlayerId)
            {
                u.IsMine = true;
            }
        }

        LogService.WriteLine("FIRETIMER: " + m_lastGame.Units.First(u => u.unit.Id == unit.Id).FireTimer);
        MCTSService.Search(sim);
        //foreach (var u in sim.Units) u.debug = true;
        MCTSService.DoOneRound(sim, true);
        //foreach (var u in sim.Units) u.debug = false;

        if (game.CurrentTick % 300 == 10)
        {
            Console.Error.WriteLine("Time: " + Const.GetTime + " Evals: " + Const.Evals + " Sims: " + Const.Sims);
        }
        var targetUnit = m_lastGame.Units.First(u => u.unit.Id == unit.Id);

        DistService.DrawPath(targetUnit.Position, targetUnit.WalkTarget);
        return(CreateAction(targetUnit, m_lastGame));
    }
コード例 #4
0
        private void RoundStart()
        {
            TimeFrozen  = false;
            _roundStart = Time.time;
            MatchController.DequeuePlayer();
            var unit = MatchController.GetCurrenUnit();

            unit.SetAllowControll(true);
            unit.SetScopeVisibility(true);

            CameraService.SetCameraFollowAndRotationTarget(unit.gameObject.transform);

            CurrentWeaponController.ResetPower();
            CurrentWeaponController.SetCurrentWeapon(ShootService.GetNoneWeapon());

            if (RoundChangedEvent != null)
            {
                RoundChangedEvent.Invoke(this, new EventArgs());
            }
            EndMatchIfNeeded();
        }
コード例 #5
0
 public void RPC_WeaponShoot(WeaponEnum weaponEnum, Vector3 position)
 {
     ShootService.WeaponShoot(weaponEnum, position);
 }
コード例 #6
0
ファイル: SimUnit.cs プロジェクト: Illedan/RAIC2019
        public void ApplyAction(MyAction action, SimGame game, double dt, bool canChange)
        {
            Spread     = Math.Max(MinSpread, Math.Min(MaxSpread, Spread - (SpreadChange * dt)));
            FireTimer -= dt;
            if (canChange)
            {
                m_jumpUp = action.JumpUp;
            }
            var dy = -JumpSpeed;

            if (game.GetTileD(Position.X + HalfWidth, Position.Y - HalffHeight) == Tile.JumpPad ||
                game.GetTileD(Position.X - HalfWidth, Position.Y - HalffHeight) == Tile.JumpPad ||
                game.GetTileD(Position.X + HalfWidth, Position.Y + HalffHeight) == Tile.JumpPad ||
                game.GetTileD(Position.X - HalfWidth, Position.Y + HalffHeight) == Tile.JumpPad)
            {
                JumpTime  = Const.Properties.JumpPadJumpTime;
                Speed     = Const.Properties.JumpPadJumpSpeed;
                CanCancel = false;
            }
            if (JumpTime > 0 && (m_jumpUp || !CanCancel))
            {
                JumpTime -= dt;
                var speed = JumpSpeed;
                if (Speed > JumpSpeed)
                {
                    speed = Speed;
                }
                dy = speed;
            }
            else
            {
                JumpTime  = 0;
                CanCancel = true;
            }

            var y = Position.Y + dy * dt;

            var tile      = game.GetTileD(Position.X - HalfWidth, y - HalffHeight);
            var otherTile = game.GetTileD(Position.X + HalfWidth, y - HalffHeight);
            var block     = 0;

            if (tile == Tile.Wall || otherTile == Tile.Wall)
            {
                block = 2;
            }
            else if (tile == Tile.Platform || otherTile == Tile.Platform)
            {
                block = 1;
            }

            var onLadder = game.GetTileD(Position.X, y) == Tile.Ladder || game.GetTileD(Position.X, y - HalffHeight) == Tile.Ladder;

            if (block == 2)
            {
                y        = Position.Y;
                JumpTime = MaxJumpTime;
            }
            else if (onLadder)
            {
                JumpTime = MaxJumpTime;
                if (m_jumpUp)
                {
                    y = Position.Y + JumpSpeed * dt;
                }
                else if (action.JumpDown)
                {
                    y = Position.Y - JumpSpeed * dt;
                }
                else
                {
                    y = Position.Y;
                }
            }
            else if (block == 1 && !action.JumpDown && (int)(Position.Y - HalffHeight) > (int)(y - HalffHeight))
            {
                y        = Position.Y;
                JumpTime = MaxJumpTime;
            }

            if (y > Position.Y)
            {
                var above  = game.GetTileD(Position.X - HalfWidth, Position.Y + HalffHeight);
                var above1 = game.GetTileD(Position.X + HalfWidth, Position.Y + HalffHeight);
                if (above == Tile.Wall || above1 == Tile.Wall)
                {
                    y         = Position.Y;
                    JumpTime  = 0;
                    Speed     = JumpSpeed;
                    CanCancel = true;
                }
            }

            foreach (var u in game.Units)
            {
                if (u == this)
                {
                    continue;
                }
                if (u.IsInside(Position.X, y))
                {
                    y = Position.Y;
                    break;
                }
            }

            var x = Position.X + action.Dx * MyAction.GetSpeed * dt;

            if (game.GetTileD(x + HalfWidth * action.Dx, Position.Y + HalffHeight) == Tile.Wall ||
                game.GetTileD(x + HalfWidth * action.Dx, Position.Y - HalffHeight) == Tile.Wall)
            {
                x = Position.X;
            }

            foreach (var u in game.Units)
            {
                if (u == this)
                {
                    continue;
                }
                if (u.IsInside(x, y))
                {
                    x = Position.X;
                    break;
                }
            }

            Position.X = x;
            Position.Y = y;

            if (canChange && ShootService.CanShootAt(Position, TargetEnemy.Position))
            {
                //if (WeaponType != WeaponType.RocketLauncher || !IsMine)
                {
                    Fire(TargetEnemy.Position, game);
                }
            }
        }