Exemple #1
0
        private void LaunchRocket(World world)
        {
            if (!RocketResources.HasEnoughForRocket(RocketMission.rocket))
            {
                return;
            }

            RocketResources.InvestInRocket(RocketMission.rocket);

            var target = Renderer.target.MapPixelToCoords(Input.mousePosition).ToVector2();

            if (!RocketMission.InTargetBounds(target.X))
            {
                return;
            }

            this.m_NextTimeFire = Time.time + 3f;

            var entity = world.CreateEntity(this.m_Arch);
            var spawn  = RocketMission.launchLocations[Player.playerId] + new Vector2(10f, -10f);

            world.SetComponentData <Position>(entity, new Position(spawn));
            world.SetComponentData <Rocket>(entity, new Rocket(Player.playerId, RocketMission.rocket, target));

            if (Player.isMultiplayer)
            {
                NetworkBuffer.Add(new RocketLaunchCommand(Player.playerId, RocketMission.rocket, target));
            }
        }
Exemple #2
0
        private void SetViewCenterToSpawn()
        {
            var position = RocketMission.GetTargetCenter();

            if (Player.playerId < RocketMission.launchLocations.Length)
            {
                position = RocketMission.launchLocations[Player.playerId];
            }

            var extends = Renderer.GetViewSize() * 0.5f;
            var viewPos = new Vector2(Math.Clamp(position.X, this.m_MinPos.X + extends.X, this.m_MaxPos.X - extends.X), position.Y + 30f);

            Renderer.view.Center = viewPos.ToVector2f();
        }
Exemple #3
0
        private void RenderCrosshair()
        {
            Vector2f position = Renderer.target.MapPixelToCoords(Input.mousePosition);

            if (RocketMission.InTargetBounds(position.X) && RocketResources.HasEnoughForRocket(RocketMission.rocket))
            {
                this.m_Crosshair.SetColor(Color.Yellow);
            }
            else
            {
                this.m_Crosshair.SetColor(Color.Red);
            }

            this.m_Crosshair.Render(position);
        }