Пример #1
0
        public static void CalculateAiPrizeTanks()
        {
            var aiPrizeTanks = State.ThisRound.AiPrizeTanks;

            if (!aiPrizeTanks.Any() || !State.HasPrevRound)
            {
                return;
            }

            foreach (var aiPrizeTank in aiPrizeTanks)
            {
                var nearPoints = aiPrizeTank.Point.GetNearPoints();

                var prevRoundNearTanks = State.PrevRound.AiTanks
                                         .Where(t => nearPoints.Contains(t.Point)).ToList();

                AiTank foundPrevRoundNearTank = null;

                if (prevRoundNearTanks.Count() == 1)
                {
                    foundPrevRoundNearTank = prevRoundNearTanks.First();
                }
                else
                {
                    foundPrevRoundNearTank = prevRoundNearTanks
                                             .FirstOrDefault(p => p.GetNextPoints(p.Point).First() == aiPrizeTank.Point);
                }


                if (foundPrevRoundNearTank != null)
                {
                    aiPrizeTank.CurrentDirection = foundPrevRoundNearTank.CurrentDirection;
                }
            }
        }
        /// <summary>
        /// Load the new map when player finishes level
        /// </summary>
        public void NextLevel()
        {
            //check if all the enemies on the current level are dead
            if (AIAllDead == true)
            {
                //increase the level by 1

                _level++;

                //delete all the projectiles from the list, which deletes all from the screen
                _projectile.Clear();
                //remove all previous enemies from the list
                AiTank.Clear();
                //remove all mines in the level (list)
                Mine.Clear();


                //send the current level the player is on, to the save file
                using (StreamWriter input = new StreamWriter((Directory.GetParent((Directory.GetParent(Environment.CurrentDirectory)).ToString()) + "/Save.txt")))
                {
                    input.Write(Level);
                }

                //draw the new map
                LoadMapString((Directory.GetParent((Directory.GetParent(Environment.CurrentDirectory)).ToString()) + "/level" + _level + ".txt").ToString());
            }
        }
Пример #3
0
    void OnTriggerEnter(Collider col)
    {
        AiTank ai = transform.parent.GetComponent <AiTank>();

        if (ai && ai.controller)
        {
            ai.controller.direction += 1;
        }
    }
Пример #4
0
    void OnTriggerEnter(Collider col)
    {
        AiTank ai = transform.parent.GetComponent <AiTank>();

        if (ai)
        {
            if (ai.controller)
            {
                if (!ai.isClever)
                {
                    ai.controller.direction = (TankController.goDirection)Random.Range(0, 4);
                }
            }
        }
    }
Пример #5
0
        public static void CalculateAiTanks()
        {
            var aiTanks = State.ThisRound.AiTanks;

            if (!State.ThisRound.AiPrizeTanks.Any() && State.HasPrevRound)
            {
                foreach (var aiTank in aiTanks)
                {
                    var nearPoints = aiTank.Point.GetNearPoints(includeThis: true);

                    var prevRoundNearPrizeTanks = State.PrevRound.AiPrizeTanks
                                                  .Where(t => nearPoints.Contains(t.Point)).ToList();

                    AiTank foundPrevRoundNearPrizeTank = null;

                    if (prevRoundNearPrizeTanks.Count() == 1)
                    {
                        foundPrevRoundNearPrizeTank = prevRoundNearPrizeTanks.First();
                    }
                    else
                    {
                        foundPrevRoundNearPrizeTank = prevRoundNearPrizeTanks
                                                      .FirstOrDefault(p => p.GetNextPoints(p.Point).First() == aiTank.Point);
                    }

                    if (foundPrevRoundNearPrizeTank != null)
                    {
                        State.ThisRound.AddAiPrizeTank(aiTank, foundPrevRoundNearPrizeTank);
                    }
                }
            }


            PredictionLogic.CalculateMobilePredictions(State.ThisRound.AiTanks, PredictionType.AiMove, x => x.CanMove);

            var stuckAiTanks = State.ThisRound.AiTanks.Where(x => x.IsStuck).ToList();

            PredictionLogic.CalculateStuckPosition(stuckAiTanks, PredictionType.AiMove, AppSettings.StuckAiPredictionDepth);

            PredictionLogic.CalculateTanksShotPredictions(State.ThisRound.AiTanks, PredictionType.AiShot, AppSettings.MyShotPredictionDepth);
        }
Пример #6
0
        /// <summary>
        ///     LoadContent will be called once per game and is the place to load
        ///     all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            GameFont = Content.Load<SpriteFont>("munro");

            MainCamera = new FirstPersonCamera(GraphicsDevice.Viewport, DefaultFieldOfView, DefaultAspectRatio, 1.0f, 10000.0f);
            SpectatorCamera = new FirstPersonCamera(GraphicsDevice.Viewport, DefaultFieldOfView, DefaultAspectRatio, 1.0f, 10000.0f);

            Axis = new Axis(GraphicsDevice)
            {
                Scale = 0.5f
            };

            Axis.Initialize(MainCamera);

            DebugHud = new DebugHud(GraphicsDevice);

            DebugStringPanel gameStateInformation = new DebugStringPanel
            {
                Padding = new Vector2(0.0f, 35.0f),
                Position = new Vector2(35.0f, 35.0f),
                SpriteFont = GameFont
            };

            gameStateInformation.Add("fps", "FPS: ", Color.Yellow, 0.8f);
            gameStateInformation.Add("delta_time", "Delta Time: ", Color.Yellow, 0.8f);
            gameStateInformation.Add("toggle_debug", "Debug Mode (F1): " + Debugging, Color.White, 1.0f);
            gameStateInformation.Add("spectate_info", "Spectator Camera (P): " + spectating, Color.White, 1.0f);

            DebugHud.DebugStringPanels.Add(gameStateInformation);

            map = new Map.Map();
            map.CreateFromHeightmap(GraphicsDevice, Content.Load<Texture2D>("heightmap"), 1, 10.0f, 0.1f);
            map.InitDebug(GraphicsDevice);

            MainCamera.Position = new Vector3(0, 0, 0);

            DefaultSamplerState = new SamplerState
            {
                Filter = TextureFilter.Anisotropic,
                MaxAnisotropy = 16,
                AddressU = TextureAddressMode.Wrap,
                AddressV = TextureAddressMode.Wrap
            };

            DefaultRasterizerState = new RasterizerState
            {
                CullMode = CullMode.CullClockwiseFace,
                MultiSampleAntiAlias = true,
                FillMode = FillMode.Solid
            };

            ground = Content.Load<Texture2D>("dirt");

            effect = new BasicEffect(GraphicsDevice)
            {
                LightingEnabled = true,
                VertexColorEnabled = false,
                TextureEnabled = true,
                Texture = ground,
                PreferPerPixelLighting = true,
                FogEnabled = false,
                FogColor = Color.SkyBlue.ToVector3(),
                FogStart = 350.0f,
                FogEnd = 2000.0f,
                EmissiveColor = Color.Black.ToVector3(),
                SpecularColor = new Vector3(0.0f, 0.0f, 0.0f),
                SpecularPower = 24,
                AmbientLightColor = Color.Green.ToVector3()
            };

            effect.EnableDefaultLighting();

            particleEffect = new BasicEffect(GraphicsDevice);
            particleEffect.VertexColorEnabled = true;
            particleEffect.TextureEnabled = false;
            particleEffect.LightingEnabled = false;
            particleEffect.Projection = MainCamera.Projection;

            BasicEffect tankEffect = new BasicEffect(GraphicsDevice)
            {
                LightingEnabled = true,
                VertexColorEnabled = false,
                TextureEnabled = true,
                PreferPerPixelLighting = true,
                SpecularPower = 24,
                SpecularColor = new Vector3(0.1f, 0.1f, 0.1f)
            };

            tankEffect.EnableDefaultLighting();

            aiTank = new AiTank(Content);
            aiTank.Position = new Vector3(60.0f, 0.0f, 60.0f);

            tank = new Tank(Content)
            {
                RasterizerState = new RasterizerState(),
                Position = new Vector3(30.0f, 0.0f, 30.0f)
            };

            tank.RasterizerState.MultiSampleAntiAlias = true;
            tank.RasterizerState.FillMode = FillMode.Solid;
            tank.RasterizerState.CullMode = CullMode.CullCounterClockwiseFace;
            tank.Scale = new Vector3(0.01f, 0.01f, 0.01f);

            aiTank.RasterizerState = tank.RasterizerState;
            aiTank.Scale = tank.Scale;
            aiTank.PlayerTank = tank;

            tank.InitDebug(GraphicsDevice);

            rainEmitter = new CircleEmitter<RainDrop>();
            rainEmitter.Position = new Vector3(map.Width * 0.5f, 100, map.Depth * 0.5f);
            rainEmitter.Interval = 0.01f;
            rainEmitter.Gravity = true;
            rainEmitter.Radius = 200;
            rainEmitter.Allocate(200);

            dustEmitter = new LineEmitter<Dust>();
            dustEmitter.Interval = 0.01f;
            dustEmitter.Position = tank.Position;
            dustEmitter.Allocate(50);
        }
Пример #7
0
 public void AddAiPrizeTank(AiTank aiTank, AiTank prevRoundAiPrizeTank)
 {
     aiTank.SetHealth(prevRoundAiPrizeTank.Health);
     aiTank.BorderColor = prevRoundAiPrizeTank.BorderColor;
     AiPrizeTanks.Add(aiTank);
 }