Inheritance: MonoBehaviour
Esempio n. 1
0
        public Game1()
        {
            graphics = new GraphicsDeviceManager(this);

            graphics.PreferredBackBufferWidth = 1366;
            graphics.PreferredBackBufferHeight = 768;

            Content.RootDirectory = "Content";

            sb = new SpriteBatch(GraphicsDevice);

            input = new InputHandler(this);

            this.Components.Add(input);

            celAnimationManager = new CelAnimationManager(this);
            this.Components.Add(celAnimationManager);

            GameManager = new GameStateManager(this);

            PlayingState = new PlayingState(this);
            PausedState = new PausedState(this);
            TitleState = new TitleIntroState(this);
            StartMenuState = new StartMenuState(this);
            EndState = new EndState(this);

            GameManager.ChangeState(TitleState.Value);
            //GameManager.ChangeState(PlayingState.Value);
        }
Esempio n. 2
0
	void Awake ()
	{
		if (Instance){
			Destroy(gameObject);
		} else {
			DontDestroyOnLoad(gameObject);
			Instance = this;
		}
		//Check PlayerPrefs to see if the three main things are saved. If not, set them to default levels.
		if(PlayerPrefs.HasKey("Score")){
			score = PlayerPrefs.GetFloat("Score");
		} else{
			score = 0;
		}
		if(PlayerPrefs.HasKey("CurrentUnlockedLevel")){
			currentUnlockedLevel = PlayerPrefs.GetInt("CurrentUnlockedLevel");
		} else{
			currentUnlockedLevel = 10;
		}
		if(PlayerPrefs.HasKey("CurrentLevel")){
			currentLevel = PlayerPrefs.GetInt("CurrentLevel");
		} else {
			currentLevel = 0;
		}
		if(PlayerPrefs.HasKey("Vibrations")){
			vibrations = PlayerPrefs.GetInt("Vibrations");
		} else {
			vibrations = 1;
		}
		ih = (InputHandler)gameObject.GetComponent(typeof(InputHandler));
	}
Esempio n. 3
0
 public override void UpdateState(GameTime time, InputHandler input)
 {
     if (KeyIsPushed(Keys.Escape))
     {
         this.EndState();
     }
     if (KeyIsPushed(Keys.Enter))
     {
         //activate selected ability
         examinedItem.Abilities[abilityNames[selectedIndex]].ItemAction(player);
         this.EndState();
     }
     if (KeyIsPushed(KeyBindings.UP))
     {
         selectedIndex = (selectedIndex > 0 ? selectedIndex - 1 : abilityNames.Count - 1);
     }
     if (KeyIsPushed(KeyBindings.DOWN))
     {
         if (selectedIndex + 1 < abilityNames.Count)
         {
             selectedIndex++;
         }
         else
         {
             selectedIndex = 0;
         }
     }
 }
 public override DragDropElement GetTopInteracting(InputHandler handler)
 {
     if (varLink != null)
         return varLink.GetElement();
     return this;
     //throw new NotImplementedException();
 }
Esempio n. 5
0
 void Awake()
 {
     if (this.inputHandler == null) {
     this.inputHandler = this.transform.parent.GetComponent<InputHandler>();
       }
       this.rigidBody = this.GetComponent<Rigidbody2D>();
 }
 public override DragDropElement GetInteracting(InputHandler handler)
 {
     if (varLink != null)
         return varLink.GetElement().GetInteracting(handler);
     else
         return this;
 }
 public DragDropElement GetInnerMostDragDrop(InputHandler handler)
 {
     if (varLink != null && varLink.GetElement().GetTopInteracting(handler) is DragDropVariablePlaceholder)
         return ((DragDropVariablePlaceholder)varLink.GetElement().GetTopInteracting(handler)).GetInnerMostDragDrop(handler);
     else
         return this;
 }
Esempio n. 8
0
        private int sameButtonPushedCount = 0; // tracks the number of times the same button was pushed in a row

        #endregion Fields

        #region Methods

        /// <summary>
        /// Starts this instance.
        /// </summary>
        void IPlugin.Start()
        {
            //File.AppendAllText(@"c:\AverRmHv.txt", "Start Llamado\n\r");

            try
            {
                rc = new RemoteClass();
                rc.Initialize();
                rc.OnRemoteData += RecibeDatos;
                //string mediaportalpath = AppDomain.CurrentDomain.ApplicationIdentity.FullName;
                string mediaportalpath = System.Reflection.Assembly.GetEntryAssembly().FullName;
                rc.SwitchBeginAP(mediaportalpath);
                Log.Info("AverRMHV Plugin: Started by " + mediaportalpath);
                //File.AppendAllText(@"c:\AverRmHv.txt", "Inicialización Correcta. Path = " + mediaportalpath);

            }
            catch (Exception e)
            {
                //File.AppendAllText(@"c:\AverRmHv.txt", "Error en Start\n\r");
                Log.Error("AverRMHV Plugin: AverRemote.exe not responding");
                Log.Error("AverRMHV Plugin: Exception: "+e);
            }

            inputhandler = new InputHandler(mappingfile);
            if (inputhandler == null || !inputhandler.IsLoaded)
            {
                //File.AppendAllText(@"c:\AverRmHv.txt", "AverRMHV Plugin: File " + mappingfile + " not loaded.\n\r");
                Log.Error("AverRMHV Plugin: File " + mappingfile + " not loaded.");
            }
            lastTimeActionPerformed = DateTime.Now;
            lastTimeButtonPushed = DateTime.Now;
            Log.Info("AverRMHV Plugin: Started.");
        }
Esempio n. 9
0
 public BackupManager(MultiBoard multiBoard, InputHandler input, HaCreatorStateManager hcsm, HaCreator.ThirdParty.TabPages.PageCollection tabs)
 {
     this.input = input;
     this.multiBoard = multiBoard;
     this.hcsm = hcsm;
     this.tabs = tabs;
 }
Esempio n. 10
0
    private void Awake() 
	{
        m_collider2D = GetComponent<Collider2D>();

        // E-man - Begin
        motherShipExplosion = GameObject.Find("MotherShipExplosion");

        if (motherShipExplosion)
        {
            motherShipExplosion.SetActive(false);
        }
        else
        {
            Debug.Log("DopHatch::Awake(), Hey buddy! Can't find your explosion guy!");
        }
        // E-man - End

        m_objectState = GetComponent<ObjectState>();

        Handler = GameObject.Find("Input Handler");
        Ihandler = Handler.GetComponent<InputHandler>();

        GameObject go = GameObject.Find("Pod");
        m_podRigidbody = go.GetComponent<Rigidbody2D>();

        // E-man
        as_explosion = GetComponent<AudioSource>();
        
        if(!fire)
        {
            Debug.Log("DopHatch::Awake(), Hey buddy! Can't seem to find your fire fwiend!");
        }
    }
    // Use this for initialization
    void Start()
    {
        stats = player.GetComponent<PlayerStats> ();
        lastPos = GetComponent<Transform>().position;

        playerInputManager = GameObject.FindGameObjectWithTag("Player").GetComponent<InputHandler>();
    }
Esempio n. 12
0
    public void Start()
    {
        input = InputData.instance.inputDevices[deviceNum];

        lastDeviceNum = deviceNum;

        input.PrimaryDirection += PrimaryDirectionDebug;
        input.SecondaryDirection += SecondaryDirectionDebug;
   
        input.Start += StartDebug;
        input.StartDown += StartDownDebug;
        input.StartUp += StartUpDebug;

        input.Back += BackDebug;
        input.BackDown += BackDownDebug;
        input.BackUp += BackUpDebug;

        input.Action1 += Action1Debug;
        input.Action1Down += Action1DownDebug;
        input.Action1Up += Action1UpDebug;

        input.Action2 += Action2Debug;
        input.Action2Down += Action2DownDebug;
        input.Action2Up += Action2UpDebug;

        input.Cancel += CancelDebug;
        input.CancelDown += CancelDownDebug;
        input.CancelUp += CancelUpDebug;

        input.Axis1 += Axis1Debug;
        input.Axis1Down += Axis1DownDebug;
        input.Axis1Up += Axis1UpDebug;

        input.Disconnect += DisconnectDebug;
    }
Esempio n. 13
0
        public StandardMelee(InputHandler handler)
        {
            _mousePosition = new Vector2f(500, 500);

            CurrentStatus = StatusState.WaitingForPlayers;

            uiState = UIStateTypes.Normal;
            currentHotkey = null;
            currentHotkeySheet = null;
            standardHotkeys = Settings.GetSheet("standard_game_mode_controls");

            InputHandler = handler;
            myId = 0;
            map = new TileMap();

            allowMinimapCameraMove = true;
            selectedUnits = null;
            controlGroups = new Dictionary<Keyboard.Key, List<EntityBase>>();

            for (int i = 27; i <= 35; i++)
            {
                controlGroups.Add((Keyboard.Key) i, new List<EntityBase>());
            }

            controlBoxP1 = new Vector2f(0, 0);
            controlBoxP2 = new Vector2f(0, 0);
            selectedAttackMove = false;
            releaseSelect = false;

            CameraPosition = new Vector2f(0, 0);

            miniMap = new MiniMap(map, Fog, entities);

            //Load Sprites
            bottomHUDGUI = new Sprite(ExternalResources.GTexture("Resources/Sprites/HUD/BottomGUI.png"));
            alertHUDAlert = new Sprite(ExternalResources.GTexture("Resources/Sprites/HUD/Alert_Alert.png"));
            alertHUDUnitCreated = new Sprite(ExternalResources.GTexture("Resources/Sprites/HUD/Alert_UnitCreated.png"));
            alertHUDBuildingCreated =
                new Sprite(ExternalResources.GTexture("Resources/Sprites/HUD/Alert_BuildingFinished.png"));

            avatarWorker = new Sprite(ExternalResources.GTexture("Resources/Sprites/HUD/HUD_AVATAR_WORKER.png"));

            hudBoxUnit = new Sprite(ExternalResources.GTexture("Resources/Sprites/HUD/HUD_BOX_Unit.png"));
            hudBoxBuilding = new Sprite(ExternalResources.GTexture("Resources/Sprites/HUD/HUD_BOX_Building.png"));

            hudControlBox = new Sprite(ExternalResources.GTexture("Resources/Sprites/HUD/ControlGroupBox.png"));
            hudControlBox.Origin = new Vector2f(hudControlBox.TextureRect.Width/2, 0);

            viewBounds = new Sprite(ExternalResources.GTexture("Resources/Sprites/Hud/ViewBounds.png"));

            //Load Sounds
            moveSound = new Sound(ExternalResources.GSoundBuffer("Resources/Audio/MoveCommand/0.wav"));
            attackMoveSound = new Sound(ExternalResources.GSoundBuffer("Resources/Audio/AttackCommand/0.wav"));

            backgroundMusic = new Music("Resources/Audio/Music/In Game/mario.wav");
            backgroundMusic.Loop = true;
            backgroundMusic.Volume = Settings.MUSICVOLUME;
            backgroundMusic.Play();
        }
 public void Update(InputHandler handler)
 {
     foreach(LevelObject obj in objects)
     {
         obj.SetEditing(false);
         obj.Update(handler);
     }
 }
Esempio n. 15
0
 protected void Awake()
 {
     controller = this.GetComponent<Prime31.CharacterController2D>();
     myPhotonView = this.GetComponent<PhotonView>();
     playerInput = this.GetComponent<InputHandler>();
     myCollider = this.GetComponent<BoxCollider2D>();
     moveState = moveStates.firstJump;
 }
 public override DragDropElement GetInteracting(InputHandler handler)
 {
     if(handler.CheckMouseIn(holder))
     {
         return holder.GetInteracting(handler);
     }
     return this;
 }
Esempio n. 17
0
    void Awake()
    {
        if (singleton == null) {
            singleton = this;
        }

        controls.UpdateControlDictionary();
    }
Esempio n. 18
0
 void Start()
 {
     // We set the controller and input handler for this object, as well as calculating the gravity and jump velocity.
     controller = GetComponent<Controller2D>();
     inputHandler = GetComponent<InputHandler>();
     gravity = -(2 * jumpHeight) / Mathf.Pow(timeToJumpApex, 2);
     jumpVelocity = Mathf.Abs(gravity) * timeToJumpApex;
 }
Esempio n. 19
0
    protected override void Awake()
    {
        base.Awake();
        m_pod = GetComponent<DropPod>();

        Handler = GameObject.Find("Input Handler");
        Ihandler = Handler.GetComponent<InputHandler>();
    }
Esempio n. 20
0
	// Up, Down, Left, Right = 0, 1, 2, 3
	
	public virtual void Start ()
	{
		rb = this.gameObject.GetComponent<Rigidbody> ();
		// TileMoving objects should never have physics push them in the y direction, nor should it rotate them.
		rb.constraints = RigidbodyConstraints.FreezePositionY | RigidbodyConstraints.FreezeRotation;
		GameObject gc = GameObject.FindGameObjectWithTag ("GameController");
		ih = (InputHandler)gc.GetComponent(typeof(InputHandler));
	}
Esempio n. 21
0
 void Awake () {
     paused = false;
     screen = GameObject.Find("GUIManager/Pause Screen/Layout");
     screen.SetActive(false);
     gui = GameObject.Find("GUIManager/Velocity_Element");
     Handler = GameObject.Find("Input Handler");
     Ihandler = Handler.GetComponent<InputHandler>();
     levelManager = transform.root.GetComponent<LevelManager>();
 }
 public override void Update(InputHandler handler)
 {
     normal = false;
     if(handler.CheckPressedKey(Keys.L) && editing)
     {
         normal = true;
     }
     base.Update(handler);
 }
Esempio n. 23
0
    void Start()
    {
        currentPos = transform.position;
        currentPos.x = (float)Random.Range (-2, 2);
        currentPos.y = (float)Random.Range (-2, 2);
        transform.position = currentPos;

        boardManager = GameObject.FindGameObjectWithTag ("InputHandler").GetComponent<InputHandler> ();
    }
Esempio n. 24
0
 public void Awake()
 {
     inputHandler = new InputHandler();
     rb = GetComponent<Rigidbody2D>();
     
     animator = GetComponent<Animator>();
     
     spriteRenderer = GetComponent<SpriteRenderer>();
 }
Esempio n. 25
0
    public void levelLoad()
    {
        mapScript = GameObject.Find ("MapAdmin").GetComponent<MapScript> ();
        inputHandler = gameObject.GetComponent<InputHandler> ();

        startLoc = mapScript.getStartLoc();

        enemyCounter = enemySpawnDelay = numEnemiesDestroyed = 0;
    }
Esempio n. 26
0
 // Use this for initialization
 void Start()
 {
     squarePixelWidth = MapInfo.squarePixelWidth;
     borderPixelWidth = MapInfo.borderPixelWidth;
     gridPixelWidth = MapInfo.gridPixelWidth;
     draggingTower = false;
     gridManager = gameObject.GetComponent<GridManager> ();
     inputHandler = gameObject.GetComponent<InputHandler> ();
 }
Esempio n. 27
0
 /// <summary>
 /// Constructor for Inputview form.
 /// </summary>
 /// <param name="add"></param>
 /// <param name="hold"></param>
 /// <param name="restart"></param>
 /// <param name="h"></param>
 public InputViewForm(InputHandler add, InputHandlerTwo hold, InputHandlerThree restart, Human h)
 {
     InitializeComponent();
     x = add;
     y = hold;
     z = restart;
     this.h = h;
     button2.Enabled = false;
 }
Esempio n. 28
0
    private void HandlePauseMenuInput(InputHandler.MappedInput input)
    {
        if (!gameObject.activeSelf) return;

        if (input.Actions.Contains("Start"))
        {
            Resume();
        }
    }
Esempio n. 29
0
        public HaCreatorStateManager(MultiBoard multiBoard, HaRibbon ribbon, PageCollection tabs, InputHandler input)
        {
            this.multiBoard = multiBoard;
            this.ribbon = ribbon;
            this.tabs = tabs;
            this.input = input;
            this.backupMan = new BackupManager(multiBoard, input, this, tabs);

            this.ribbon.NewClicked += ribbon_NewClicked;
            this.ribbon.OpenClicked += ribbon_OpenClicked;
            this.ribbon.SaveClicked += ribbon_SaveClicked;
            this.ribbon.RepackClicked += ribbon_RepackClicked;
            this.ribbon.AboutClicked += ribbon_AboutClicked;
            this.ribbon.HelpClicked += ribbon_HelpClicked;
            this.ribbon.SettingsClicked += ribbon_SettingsClicked;
            this.ribbon.ExitClicked += ribbon_ExitClicked;
            this.ribbon.ViewToggled += ribbon_ViewToggled;
            this.ribbon.ShowMinimapToggled += ribbon_ShowMinimapToggled;
            this.ribbon.ParallaxToggled += ribbon_ParallaxToggled;
            this.ribbon.LayerViewChanged += ribbon_LayerViewChanged;
            this.ribbon.MapSimulationClicked += ribbon_MapSimulationClicked;
            this.ribbon.RegenerateMinimapClicked += ribbon_RegenerateMinimapClicked;
            this.ribbon.SnappingToggled += ribbon_SnappingToggled;
            this.ribbon.RandomTilesToggled += ribbon_RandomTilesToggled;
            this.ribbon.InfoModeToggled += ribbon_InfoModeToggled;
            this.ribbon.HaRepackerClicked += ribbon_HaRepackerClicked;
            this.ribbon.FinalizeClicked += ribbon_FinalizeClicked;
            this.ribbon.NewPlatformClicked += ribbon_NewPlatformClicked;
            this.ribbon.UserObjsClicked += ribbon_UserObjsClicked;
            this.ribbon.ExportClicked += ribbon_ExportClicked;
            this.ribbon.RibbonKeyDown += multiBoard.DxContainer_KeyDown;

            this.tabs.CurrentPageChanged += tabs_CurrentPageChanged;
            this.tabs.PageClosing += tabs_PageClosing;
            this.tabs.PageRemoved += tabs_PageRemoved;

            this.multiBoard.OnBringToFrontClicked += multiBoard_OnBringToFrontClicked;
            this.multiBoard.OnEditBaseClicked += multiBoard_OnEditBaseClicked;
            this.multiBoard.OnEditInstanceClicked += multiBoard_OnEditInstanceClicked;
            this.multiBoard.OnLayerTSChanged += multiBoard_OnLayerTSChanged;
            this.multiBoard.OnSendToBackClicked += multiBoard_OnSendToBackClicked;
            this.multiBoard.ReturnToSelectionState += multiBoard_ReturnToSelectionState;
            this.multiBoard.SelectedItemChanged += multiBoard_SelectedItemChanged;
            this.multiBoard.MouseMoved += multiBoard_MouseMoved;
            this.multiBoard.ImageDropped += multiBoard_ImageDropped;
            this.multiBoard.ExportRequested += ribbon_ExportClicked;
            this.multiBoard.LoadRequested += ribbon_OpenClicked;
            this.multiBoard.CloseTabRequested += multiBoard_CloseTabRequested;
            this.multiBoard.SwitchTabRequested += multiBoard_SwitchTabRequested;
            this.multiBoard.BackupCheck += multiBoard_BackupCheck;
            this.multiBoard.BoardRemoved += multiBoard_BoardRemoved;
            this.multiBoard.MinimapStateChanged += multiBoard_MinimapStateChanged;

            multiBoard.Visible = false;
            ribbon.SetEnabled(false);
        }
Esempio n. 30
0
 /// <summary>
 /// Loads the content.
 /// @see GetScores
 /// @see TrierLaListe
 /// </summary>
 /// <param name="_content">The _content.</param>
 public void LoadContent(ContentManager _content)
 {
     content = _content;
     scores = new List<Score>();
     input = DespicableGame.input;
     XMLScoreReader reader = new XMLScoreReader();
     reader.Load("Scores.xml");
     scores = reader.GetScores();
     TrierLaListe();
 }
        internal void Draw(SpriteBatch spriteBatch, GameTime gameTime)
        {
            switch (op.NewGameState)
            {
            case EventOperator.MENU_STATE:
                #region SplashScreen
                if (op.GameState == EventOperator.SPLASH_SCREEN_STATE)
                {
                    if (InputHandler.isJustPressed(MouseButton.LEFT))
                    {
                        eventTimer.Finish();
                    }
                    else
                    {
                        int alphaChannel = (int)(455 * (SPLASHTIME - eventTimer.currentTime) / SPLASHTIME) - 100;
                        logo.MColor = new Color(255, 255, 255, alphaChannel);
                        logo.Draw(spriteBatch, gameTime);
                    }
                }
                #endregion
                #region GiveUp
                else
                {
                    op.ResetGame(false);
                    game.UpdateGame(gameTime, false);
                    game.DrawGame(spriteBatch, gameTime, false);
                    string s = "Mediocre!";     //!
                    spriteBatch.DrawOutlinedString(3, new Color(32, 32, 32), font, s, DrawHelper.CenteredWordPosition(s, font), Color.Gold);
                }
                #endregion
                break;

            case EventOperator.GAME_STATE:
                #region CountDown
                game.DrawGame(spriteBatch, gameTime, false);
                DrawCountDown(spriteBatch, gameTime);
                #endregion
                break;

            case EventOperator.GAME_OVER_STATE:
                #region GameOver Animation
                if (eventTimer.currentTime > STATSTIME)
                {
                    game.UpdateGame(gameTime, false);
                    game.DrawGame(spriteBatch, gameTime, false);
                    Vector2 shitvect = new Vector2(WindowSize.Width / 2 - font.MeasureString("GAME OVER").X / 2, WindowSize.Height / 2 - font.MeasureString("GAME OVER").Y / 2);          //previously bigFont in Game1
                    spriteBatch.DrawOutlinedString(3, new Color(32, 32, 32), font, "GAME OVER", shitvect, Color.OrangeRed);
                }
                #endregion
                #region DrawStats
                else
                {
                    SoundHandler.PlaySong((int)IDs.GAMEOVER);
                    DrawStats(spriteBatch, gameTime);
                    if (InputHandler.isJustPressed(MouseButton.LEFT))
                    {
                        eventTimer = new Timer(0);
                    }
                }
                #endregion
                break;

            case EventOperator.CUT_SCENE_STATE:
                #region Cutscenes
                switch (op.CutSceneType)
                {
                case 1:

                    BossFinishedScene(spriteBatch, gameTime);
                    break;

                case 2:
                    BossAppearanceScene(spriteBatch, gameTime);
                    break;
                }
                #endregion
                break;
            }
        }
Esempio n. 32
0
 void Start()
 {
     //recebe os inputs do player
     input = GameObject.FindGameObjectWithTag("Player").GetComponent <InputHandler>();
     MemoryManager.OnMemoryReset += resetTimer;
 }
Esempio n. 33
0
 public virtual void onInput(InputHandler input)
 {
 }
Esempio n. 34
0
 public void RegisterHandler(InputHandler handler)
 {
     inputHandler = handler;
 }
Esempio n. 35
0
        public void Update(GameTime gameTime, MapLayer tilemap)
        {
            createBullet = false;
            playerOrigin = new Vector2(animatedSprite.Position.X + animatedSprite.Width / 2, animatedSprite.Position.Y + animatedSprite.Height / 2);
            animatedSprite.Update(gameTime);

            if (InputHandler.KeyReleased(Keys.Z) || InputHandler.Scroll(Mouse.GetState()) == 1 ||
                InputHandler.ButtonReleased(Buttons.LeftShoulder, PlayerIndex.One))
            {
                camera.Zoom(0.25f);
                camera.LockToSprite(animatedSprite);
            }

            else if (InputHandler.KeyReleased(Keys.X) || InputHandler.Scroll(Mouse.GetState()) == -1 ||
                     InputHandler.ButtonReleased(Buttons.RightShoulder, PlayerIndex.One))
            {
                camera.Zoom(-0.25f);
                camera.LockToSprite(animatedSprite);
            }
            motion = new Vector2();
            if (InputHandler.KeyDown(Keys.W) ||
                InputHandler.ButtonDown(Buttons.LeftThumbstickUp, PlayerIndex.One))
            {
                animatedSprite.currentAnimation = Constants.Direction.Up;
                if (checkIfCanWalkOnTile(tilemap, 0, -3) == 2)
                {
                    completedLevel = true;
                }
                if (checkIfCanWalkOnTile(tilemap, 0, -3) == 1)
                {
                    motion.Y = -9;
                }
            }
            else if (InputHandler.KeyDown(Keys.S) ||
                     InputHandler.ButtonDown(Buttons.LeftThumbstickDown, PlayerIndex.One))
            {
                animatedSprite.currentAnimation = Constants.Direction.Down;
                if (checkIfCanWalkOnTile(tilemap, 0, 3) == 2)
                {
                    completedLevel = true;
                }
                if (checkIfCanWalkOnTile(tilemap, 0, 3) == 1)
                {
                    motion.Y = 9;
                }
            }
            if (InputHandler.KeyDown(Keys.A) ||
                InputHandler.ButtonDown(Buttons.LeftThumbstickLeft, PlayerIndex.One))
            {
                animatedSprite.currentAnimation = Constants.Direction.Left;
                if (checkIfCanWalkOnTile(tilemap, -3, 0) == 2)
                {
                    completedLevel = true;
                }
                if (checkIfCanWalkOnTile(tilemap, -3, 0) == 1)
                {
                    motion.X = -9;
                }
            }
            if (InputHandler.KeyDown(Keys.D) ||
                InputHandler.ButtonDown(Buttons.LeftThumbstickRight, PlayerIndex.One))
            {
                animatedSprite.currentAnimation = Constants.Direction.Right;
                if (checkIfCanWalkOnTile(tilemap, 3, 0) == 2)
                {
                    completedLevel = true;
                }
                if (checkIfCanWalkOnTile(tilemap, 3, 0) == 1)
                {
                    motion.X = 9;
                }
            }



            if (motion != Vector2.Zero)
            {
                animatedSprite.isAnimating = true;
                motion.Normalize();
                animatedSprite.Position += motion * animatedSprite.Speed;
                animatedSprite.LockToMap();
                camera.LockToSprite(animatedSprite);
            }
            else
            {
                animatedSprite.isAnimating = false;
            }
            if (InputHandler.KeyPressed(Keys.Space) ||
                InputHandler.ButtonDown(Buttons.A, PlayerIndex.One))
            {
                bullets.Add(new Bullet(bulletSprite, playerOrigin, animatedSprite.currentAnimation.ToString(), motion));
                createBullet = true;
            }

            foreach (Bullet bullet in bullets)
            {
                bullet.Update(gameTime, tilemap);
            }

            UpdateHealthBar();

            playerHealth.Update(gameTime);
        }
Esempio n. 36
0
        public override void Update(GameTime gameTime)
        {
            menuComponent.Update(gameTime, null);

            if (staffLightIntensity <= 250)
            {
                staffLightIntensity += (700f * (float)gameTime.ElapsedGameTime.TotalSeconds);
            }

            staffLight.Scale = new Vector2(staffLightIntensity);

            if (InputHandler.KeyReleased(Keys.Space) || InputHandler.KeyReleased(Keys.Enter) || InputHandler.MouseReleased(MouseButton.Left))
            {
                // TODO: Implement next states
                switch (menuComponent.SelectedIndex)
                {
                case 0:
                {
                    try
                    {
                        GameReference.PlayState.LoadGame();
                        GameReference.PlayState.StartGame();

                        // manager.PushState((PlayState)GameReference.PlayState, playerInControl);
                    }
                    catch
                    {
                    }
                    break;
                }

                case 1:
                {
                    log.Info("Starting game");
                    GameReference.PlayState.NewGame();
                    GameReference.PlayState.StartGame();

                    log.Debug("Pushing play state");
                    manager.PushState((PlayState)GameReference.PlayState, playerInControl);
                    break;
                }

                case 2:
                    break;

                case 3:
                    log.Info("Exiting game");
                    Game.Exit();
                    break;
                }
            }

            base.Update(gameTime);
        }
Esempio n. 37
0
        public override void Update(GameTime gameTime)
        {
            //if (InputHandler.PressedCancel() && _passStep != 8)
            //    Game.Exit();

            if (InputHandler.PressedUp())
            {
                _menuIndex--;

                if (_menuIndex < 0)
                {
                    _menuIndex = _menuText.Length - 1;
                }

                select.Play();
            }

            if (InputHandler.PressedDown())
            {
                _menuIndex = (_menuIndex + 1) % _menuText.Length;
                select.Play();
            }

            if (InputHandler.PressedAction() && _passStep != 9)
            {
                choose.Play();

                // 1 Player
                if (_menuIndex == 0)
                {
                    StateManager.ChangeState(GameStateManager.State.GameplayScreen);
                }
                // Improvements
                else if (_menuIndex == 1)
                {
                    StateManager.ChangeState(GameStateManager.State.ImprovementScreen);
                }
                // Options
                else if (_menuIndex == 2)
                {
                    StateManager.ChangeState(GameStateManager.State.OptionsScreen);
                }
                // Exit
                else if (_menuIndex == 3)
                {
                    Process.GetCurrentProcess().Kill();
                }
            }

            if (_backgroundMainRectangle.X + Config.Resolution.X <= 0)
            {
                _backgroundMainRectangle.X = _backgroundRightRectangle.X + Config.Resolution.X;
            }

            if (_backgroundRightRectangle.X + Config.Resolution.X <= 0)
            {
                _backgroundRightRectangle.X = _backgroundMainRectangle.X + Config.Resolution.X;
            }

            /*
             * if (_backgroundMainRectangle.Y + _backgroundImage.Height <= 0)
             *  _backgroundMainRectangle.Y = _backgroundTopRectangle.Y - _backgroundImage.Height;
             *
             * if (_backgroundTopRectangle.Y + _backgroundImage.Height <= 0)
             *  _backgroundTopRectangle.Y = _backgroundMainRectangle.Y - _backgroundImage.Height;
             */


            _backgroundMainRectangle.X  -= (int)(70 * (float)gameTime.ElapsedGameTime.TotalSeconds);
            _backgroundRightRectangle.X -= (int)(70 * (float)gameTime.ElapsedGameTime.TotalSeconds);

            // Cheat and debug mode
            if (!Config.Cheat)
            {
                if ((_passStep == 0 || _passStep == 1) && InputHandler.PressedUp())
                {
                    _passStep++;
                }
                else if ((_passStep == 2 || _passStep == 3) && InputHandler.PressedDown())
                {
                    _passStep++;
                }
                else if ((_passStep == 4 || _passStep == 6) && InputHandler.PressedLeft())
                {
                    _passStep++;
                }
                else if ((_passStep == 5 || _passStep == 7) && InputHandler.PressedRight())
                {
                    _passStep++;
                }
                else if (_passStep == 8 && (InputHandler.PressedCancel() || InputHandler.KeyPressed(Keys.B)))
                {
                    _passStep++;
                }
                else if (_passStep == 9 && (InputHandler.PressedAction() || InputHandler.KeyPressed(Keys.A)))
                {
                    _passStep++;
                }

                if (_passStep == 10)
                {
                    Config.Cheat = true;
                    _passSound.Play();
                }
            }
            else if (InputHandler.KeyDown(Keys.F9))
            {
                Config.Debug = !Config.Debug;
            }

            if (Config.Cheat)
            {
                if (InputHandler.KeyDown(Keys.A) || InputHandler.ButtonDown(Buttons.Y, PlayerIndex.One))
                {
                    PlayerData.Credits += 1000;
                }
            }

            base.Update(gameTime);
        }
        public override void Update(float dtime)
        {
            Renderer.Settings.WaterLevel     = MainWindow.Instance.CurrentMap.Settings.WaterHeight;
            Renderer.Settings.AmbientColor   = MainWindow.Instance.CurrentMap.Settings.AmbientColor;
            Renderer.Settings.DiffuseColor   = MainWindow.Instance.CurrentMap.Settings.DiffuseColor;
            Renderer.Settings.FogColor       = MainWindow.Instance.CurrentMap.Settings.FogColor;
            Renderer.Settings.SpecularColor  = MainWindow.Instance.CurrentMap.Settings.SpecularColor;
            Renderer.Settings.LightDirection = MainWindow.Instance.CurrentMap.Settings.LightDirection;
            if (FogEnabled)
            {
                Renderer.Settings.FogDistance = MainWindow.Instance.CurrentMap.Settings.FogDistance;
                Renderer.Settings.FogExponent = MainWindow.Instance.CurrentMap.Settings.FogExponent;
            }
            else
            {
                Renderer.Settings.FogDistance = 100000;
                Renderer.Settings.FogExponent = 100000;
            }

            Renderer.CalcShadowmapCamera(Renderer.Settings.LightDirection, 0);

            if (sceneQuadtree != null)
            {
                SceneRendererConnector.CullScene(sceneQuadtree);
            }

            SceneRendererConnector.UpdateAnimations(dtime);

            if (InputHandler != null)
            {
                InputHandler.ProcessMessage(MessageType.Update, new UpdateEventArgs {
                    Dtime = dtime
                });
            }

            Renderer.PreRender(dtime);

            Device9.Clear(ClearFlags.Target | ClearFlags.ZBuffer, new Color4(Renderer.Settings.FogColor), 1.0f, 0);
            Device9.BeginScene();

            if (Wireframe)
            {
                Device9.SetRenderState(RenderState.FillMode, FillMode.Wireframe);
            }
            else
            {
                Device9.SetRenderState(RenderState.FillMode, FillMode.Solid);
            }

            Renderer.Render(dtime);
            state.OnRender();

            bvRenderer.Begin(Scene.Camera);

            if (Program.Settings.DisplayGroundBoundings)
            {
                foreach (var v in MainWindow.Instance.CurrentMap.Ground.quadtree.All)
                {
                    var b = MainWindow.Instance.CurrentMap.Ground.quadtree.GetBounding(v);
                    bvRenderer.Draw(Matrix.Identity, b, Color.Yellow);
                }
            }

            if (MainWindow.Instance.placementBoundingsToolStripMenuItem.Checked)
            {
                foreach (var v in PlacementBoundings.All)
                {
                    var b = ((Client.Game.Map.GameEntity)v).EditorPlacementWorldBounding;
                    bvRenderer.Draw(Matrix.Identity, b, Color.Yellow);
                }
            }

            helperVisualizations.Settings.PhysicsBoundings           = MainWindow.Instance.physicsBoundingsToolStripMenuItem.Checked;
            helperVisualizations.Settings.PhysicsBoundingsFullChains = MainWindow.Instance.showFullChainsToolStripMenuItem.Checked;
            helperVisualizations.Settings.PhysicsBoundingsHideGround = MainWindow.Instance.physicsBoundingsHideGroundToolStripMenuItem.Checked;
            helperVisualizations.Settings.AggroRange      = MainWindow.Instance.aggroRangeToolStripMenuItem.Checked;
            helperVisualizations.Settings.VisualBoundings = MainWindow.Instance.visualBoundingsToolStripMenuItem.Checked;

            helperVisualizations.Render(bvRenderer,
                                        this,
                                        Scene,
                                        MainWindow.Instance.CurrentMap.NavMesh,
                                        Renderer.Frame);

            if (MainWindow.Instance.mapBoundsToolStripMenuItem.Checked)
            {
                float border = 20;
                bvRenderer.Draw(Matrix.Identity, new BoundingBox(
                                    new Vector3(border, border, 0),
                                    new Vector3(MainWindow.Instance.CurrentMap.Settings.Size.Width - border,
                                                MainWindow.Instance.CurrentMap.Settings.Size.Height - border, 0)
                                    ), Color.Black);
            }

            if (MainWindow.Instance.pickingBoundingsToolStripMenuItem.Checked)
            {
                foreach (var v in Scene.AllEntities)
                {
                    if (v is Client.Game.Map.GameEntity)
                    {
                        bvRenderer.Draw(Matrix.Identity,
                                        v.PickingWorldBounding,
                                        Color.Orange);
                    }
                }
            }

            bvRenderer.End();

            Device9.EndScene();
            Device9.Present();
        }
Esempio n. 39
0
        public override void Update(GameTime gameTime)
        {
            if (paused)
            {
                if (InputHandler.IsKeyJustPressed(Keys.Space))
                {
                    paused = false;
                    Constants.G_SOUNDS_PAUSE.Play();
                }
                else
                {
                    return;
                }
            }
            else if (InputHandler.IsKeyJustPressed(Keys.Space))
            {
                paused = true;
                Constants.G_SOUNDS_PAUSE.Play();
            }

            base.Update(gameTime);

            if (ball.Collides(paddle.BoundingBox))
            {
                ball.Y  = paddle.BoundingBox.Y - ball.BoundingBox.Height;
                ball.Dy = -ball.Dy;

                if (ball.X < paddle.BoundingBox.X + (paddle.BoundingBox.Width / 2) && paddle.Dx < 0)
                {
                    ball.Dx = -50 + -(8 * (paddle.BoundingBox.X + paddle.BoundingBox.Width / 2 - ball.X));
                }
                else if (ball.X > paddle.BoundingBox.X + (paddle.BoundingBox.Width / 2) && paddle.Dx > 0)
                {
                    ball.Dx = 50 + (8 * Math.Abs(paddle.BoundingBox.X + paddle.BoundingBox.Width / 2 - ball.X));
                }
                Constants.G_SOUNDS_PADDLE_HIT.Play();
            }

            foreach (Brick brick in bricks)
            {
                if (brick.InPlay && ball.Collides(brick.BoundingBox))
                {
                    brick.Hit();
                    score += 10;

                    if (ball.X + 2 < brick.BoundingBox.X && ball.Dx > 0)
                    {
                        ball.Dx = -ball.Dx;
                        ball.X  = brick.BoundingBox.X - 8;
                    }
                    else if (ball.X + 6 > brick.BoundingBox.X + brick.BoundingBox.Width && ball.Dx < 0)
                    {
                        ball.Dx = -ball.Dx;
                        ball.X  = brick.BoundingBox.X + 32;
                    }
                    else if (ball.Y < brick.BoundingBox.Y)
                    {
                        ball.Dy = -ball.Dy;
                        ball.Y  = brick.BoundingBox.Y - 8;
                    }
                    else
                    {
                        ball.Dy = -ball.Dy;
                        ball.Y  = brick.BoundingBox.Y + 16;
                    }
                    ball.Dy = ball.Dy * 1.02f;
                }
            }

            if (ball.Y >= Constants.VIRTUAL_HEIGHT)
            {
                health--;
                Constants.G_SOUNDS_HURT.Play();
                if (health == 0)
                {
                    manager.ChangeState(new GameOverState(this.Game, score));
                }
                else
                {
                    ServeState serveState = new ServeState(this.Game, paddle, health, score, bricks);
                    manager.ChangeState(serveState);
                }
            }

            if (InputHandler.IsKeyJustPressed(Keys.Escape))
            {
                Game.Exit();
            }
        }
Esempio n. 40
0
 public PaddleController(Game game, Ball ball)
 {
     input          = (InputHandler)game.Services.GetService(typeof(IInputHandler));
     this.Direction = Vector2.Zero;
     this.ball      = ball; //need refernce to ball to be able to lanch ball could possibly use delegate here
 }
        public PolygonEditor()
        {
            InitializeComponent();
            StartPosition = FormStartPosition.CenterScreen;

            polygons = new List <IPolygon> {
                PolygonCreator.GetCustom()
            };
            Vertice.ClickRadius = 10;
            Edge.ClickDistance  = 5;

            inputHandler = GetStandardInputHandler();

            standardPolygonDrawer = new PolygonDrawer
            {
                EdgeColor              = Color.LightGray,
                EdgeThickness          = 2,
                VerticeBorderColor     = Color.LightGray,
                VerticeInsideColor     = Color.FromArgb(28, 28, 28),
                VerticeBorderThickness = 1,
                VerticeRadius          = 10,
                IconLineThickness      = 1,
                IconRadius             = 12,
                IconColor              = Color.Yellow,
                IconFontName           = "Arial",
                IconFontSize           = 12
            };

            selectedElementDrawer = new PolygonDrawer
            {
                EdgeColor              = Color.Red,
                EdgeThickness          = standardPolygonDrawer.EdgeThickness,
                VerticeBorderColor     = Color.Red,
                VerticeInsideColor     = standardPolygonDrawer.VerticeInsideColor,
                VerticeBorderThickness = standardPolygonDrawer.VerticeBorderThickness,
                VerticeRadius          = standardPolygonDrawer.VerticeRadius,
                IconLineThickness      = standardPolygonDrawer.IconLineThickness,
                IconRadius             = standardPolygonDrawer.IconRadius,
                IconColor              = standardPolygonDrawer.IconColor,
                IconFontName           = standardPolygonDrawer.IconFontName,
                IconFontSize           = standardPolygonDrawer.IconFontSize
            };

            #region Events pinning

            drawingArea.Paint += Draw;
            AttachInputHandlerEventsToDrawingArea();

            MakeVerticalButton.Click      += ChangeSelectedEdgeToVertical;
            MakeHorizontalButton.Click    += ChangeSelectedEdgeToHorizontal;
            MakeFixedLengthButton.Click   += ChangeSelectedEdgeToFixedLength;
            ChangeLengthButton.Click      += ChangeSelectedEdgeLength;
            RemoveConstraintsButton.Click += RemoveConstraintsFromSelectedEdge;
            DeleteVerticeButton.Click     += DeleteSelectedVertice;
            SplitButton.Click             += SplitSelectedEdge;

            CreateTriangleButton.Click  += CreateTriangle;
            CreateRectangleButton.Click += CreateRectangle;
            CreateCustomButton.Click    += CreateCustomPolygon;
            DeletePolygonButton.Click   += DeleteSelectedPolygon;
            StartDrawingButton.Click    += StartDrawingPolygon;
            StopDrawingButton.Click     += StopDrawingPolygon;
            ConvexHullButton.Click      += ChangeCurrentPolygonToConvexHull;

            #endregion

            UpdateButtons();
        }
Esempio n. 42
0
        public override void Update(GameTime gameTime)
        {
            base.Update(gameTime);

            if (InputHandler.PressedCancel())
            {
                UnloadContent();
                StateManager.ChangeState(GameRef.TitleScreen);
            }
            else if (InputHandler.KeyPressed(Keys.P))
            {
                GameRef.Pause = !GameRef.Pause;
            }

            if (GameRef.Pause)
            {
                return;
            }

            HandleInput();

            foreach (var p in Players)
            {
                if (p.IsAlive)
                {
                    if (p.BulletTime)
                    {
                        var newGameTime = new GameTime(
                            gameTime.TotalGameTime,
                            new TimeSpan((long)(gameTime.ElapsedGameTime.Ticks / Improvements.BulletTimeDivisorData[PlayerData.BulletTimeDivisorIndex].Key))
                            );

                        gameTime = newGameTime;
                    }

                    for (var i = 0; i < p.GetBullets().Count; i++)
                    {
                        var currentPlayerBullet = p.GetBullets()[i];
                        currentPlayerBullet.Update(gameTime);

                        if (_boss.Intersects(currentPlayerBullet))
                        {
                            //_boss.TakeDamage(currentPlayerBullet.Power);

                            for (var j = 0; j < 30; j++)
                            {
                                GameRef.ParticleManager.CreateParticle(GameRef.LineParticle,
                                                                       currentPlayerBullet.Position, Color.LightBlue, 50, 1,
                                                                       new ParticleState()
                                {
                                    Velocity         = GameRef.Rand.NextVector2(0, 9),
                                    Type             = ParticleType.Bullet,
                                    LengthMultiplier = 1
                                });
                            }

                            p.GetBullets().Remove(currentPlayerBullet);
                            continue;
                        }

                        if (currentPlayerBullet.X < 0 || currentPlayerBullet.X > Config.GameArea.X ||
                            currentPlayerBullet.Y < 0 || currentPlayerBullet.Y > Config.GameArea.Y)
                        {
                            for (var j = 0; j < 30; j++)
                            {
                                GameRef.ParticleManager.CreateParticle(GameRef.LineParticle,
                                                                       currentPlayerBullet.Position, Color.LightBlue, 50, 1,
                                                                       new ParticleState()
                                {
                                    Velocity         = GameRef.Rand.NextVector2(0, 9),
                                    Type             = ParticleType.Bullet,
                                    LengthMultiplier = 1
                                });
                            }

                            p.GetBullets().Remove(currentPlayerBullet);
                        }

                        /*
                         * // Collision with turrets
                         * for (int j = 0; j < _boss.Turrets.Count; j++)
                         * {
                         *  if (_boss.Turrets[j].Intersects(p.GetBullets()[i]))
                         *  {
                         *      _boss.Turrets[j].Color = Color.Blue;
                         *      _boss.DestroyTurret(_boss.Turrets[j], p.GetBullets()[i]);
                         *      p.GetBullets().Remove(p.GetBullets()[i]);
                         *      break;
                         *  }
                         * }
                         */
                    }

                    p.Update(gameTime);
                }
            }

            _boss.Update(gameTime);

            GameRef.ParticleManager.Update();
        }
Esempio n. 43
0
    //
    // Unity Methods
    //

    private void Awake()
    {
        inputHandler = ComponentManager.Instance.Get <InputHandler>();
        classificationToMinutesPerMeter = new float[(int)Math.Pow(2, ClassificationValue.Count - 1)];
    }
Esempio n. 44
0
 public void setInput(InputHandler i)
 {
     inputs = i;
 }
Esempio n. 45
0
 // Use this for initialization
 void Start()
 {
     touchOrMouseListener = InputEvent.AddListenerTouchOrMouse(TouchOrMouseStart, null, null, 1.0f);
     colliders            = GetComponentsInChildren <Collider2D>();
 }
Esempio n. 46
0
 public abstract void Update(GameTime gameTime, InputHandler input);
Esempio n. 47
0
    //
    // Unity Methods
    //

    private void OnEnable()
    {
        map          = ComponentManager.Instance.Get <MapController>();
        dataLayers   = ComponentManager.Instance.Get <DataLayers>();
        inputHandler = ComponentManager.Instance.Get <InputHandler>();
    }
Esempio n. 48
0
 public void UseSpell()
 {
     InputHandler.SendKeys(new string[] { SpellHotkey }, 100);
 }
Esempio n. 49
0
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            Graphics.PreferredBackBufferWidth  = Constants.InternalResolutionWidth;
            Graphics.PreferredBackBufferHeight = Constants.InternalResolutionHeight;

            Graphics.SynchronizeWithVerticalRetrace = false;
            IsFixedTimeStep = false;

            Graphics.ApplyChanges();

            //Components.Add(new FrameRateCounter(this, "Content\\Fonts\\fpsfont", 1f));
            Components.Add(new GameObjectInfoDisplay(this, 0.5f, "Content\\Fonts\\debugfont", new Vector2(0f, 25f)));


            var componentFactory  = new ComponentFactory();
            var gameObjectFactory = new GameObjectFactory(this.Content);

            gameObjectFactory.PathToXML = "EntityDefinitions\\entity.xml";

            var inputHandler  = new InputHandler(false);
            var playerManager = new PlayerManager();

            var collisionManager = new CollisionManager(new RectangleF(0f, 0f, Constants.InternalResolutionWidth, Constants.InternalResolutionHeight));

            particleManager = new ParticleManager(Content, "ParticleEffects\\", "Textures\\");

            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);

            renderer = new Renderer(Graphics, spriteBatch);
            renderer.SpriteSortMode = SpriteSortMode.FrontToBack;
            renderer.SetInternalResolution(Constants.InternalResolutionWidth, Constants.InternalResolutionHeight);
            renderer.SetScreenResolution(1920, 1080, false);

            cameraService = new CameraManager();

            var camera = new BasicCamera2D(GraphicsDevice, "main");

            cameraService.AddCamera(camera);

            GameServiceManager.AddService(typeof(IGameObjectFactory), gameObjectFactory);
            GameServiceManager.AddService(typeof(IComponentFactory), componentFactory);
            GameServiceManager.AddService(typeof(RenderableFactory), new RenderableFactory(Content));
            GameServiceManager.AddService(typeof(IInputHandler), inputHandler);
            GameServiceManager.AddService(typeof(PlayerManager), playerManager);
            GameServiceManager.AddService(typeof(IGameObjectManager), new GameObjectManager());
            GameServiceManager.AddService(typeof(ICollisionManager), collisionManager);
            GameServiceManager.AddService(typeof(IBehaviorFactory), new BehaviorFactory());
            GameServiceManager.AddService(typeof(IActionFactory), new ActionFactory());
            GameServiceManager.AddService(typeof(IRandomGenerator), new RandomGenerator());
            GameServiceManager.AddService(typeof(IParticleManager), particleManager);
            GameServiceManager.AddService(typeof(IProjectileManager), new ProjectileManager());
            GameServiceManager.AddService(typeof(IActionManager), new ActionManager());
            GameServiceManager.AddService(typeof(ILayerManager), new LayerManager("layers.xml", Content));
            GameServiceManager.AddService(typeof(IRenderer), renderer);
            GameServiceManager.AddService(typeof(ICameraService), cameraService);
            GameServiceManager.AddService(typeof(ILevelLogicManager), new LevelLogicManager());

            //Initialize the GameServices););
            foreach (var service in GameServiceManager.Services)
            {
                service.Initialize();
            }

            base.Initialize();
        }
Esempio n. 50
0
 public AutoInputOp(InputHandler inputHandler)
 {
     _inputHandler = inputHandler;
 }
Esempio n. 51
0
        public override void Update(GameTime gameTime)
        {
            base.Update(gameTime);

            scene.Update(gameTime, playerIndexInControl);

            switch (State)
            {
            case ShopStateType.Buy:
                if (isFirst)
                {
                    isFirst = false;
                    break;
                }

                if (InputHandler.KeyReleased(Keys.Down) ||
                    InputHandler.KeyReleased(Keys.S))
                {
                    selected++;
                    if (selected >= merchant.Backpack.Items.Count)
                    {
                        selected = 0;
                    }
                }

                if (InputHandler.KeyReleased(Keys.Up) ||
                    InputHandler.KeyReleased(Keys.W))
                {
                    selected--;
                    if (selected < 0)
                    {
                        selected = merchant.Backpack.Items.Count - 1;
                    }
                }

                if (InputHandler.KeyReleased(Keys.Space) ||
                    InputHandler.KeyReleased(Keys.Enter) ||
                    (InputHandler.CheckMouseReleased(MouseButton.Left) && mouseOver))
                {
                    if (selected != -1 &&
                        GamePlayScreen.Player.Gold >=
                        merchant.Backpack.PeekItem(
                            merchant.Backpack.Items[selected].Item.Name).Price)
                    {
                        if (selected >= merchant.Backpack.Items.Count)
                        {
                            return;
                        }

                        GamePlayScreen.Player.Gold -=
                            merchant.Backpack.PeekItem(
                                merchant.Backpack.Items[selected].Item.Name).Price;
                        GamePlayScreen.Player.Backpack.AddItem(
                            merchant.Backpack.GetItem(
                                merchant.Backpack.Items[selected].Item.Name));
                    }
                }
                break;

            case ShopStateType.Sell:
                if (isFirst)
                {
                    isFirst = false;
                    break;
                }

                if (InputHandler.KeyReleased(Keys.Down) ||
                    InputHandler.KeyReleased(Keys.S))
                {
                    selected++;

                    if (selected >= GamePlayScreen.Player.Backpack.Items.Count)
                    {
                        selected = 0;
                    }
                }

                if (InputHandler.KeyReleased(Keys.Up) ||
                    InputHandler.KeyReleased(Keys.W))
                {
                    selected--;
                    if (selected < 0)
                    {
                        selected = GamePlayScreen.Player.Backpack.Items.Count - 1;
                    }
                }

                if ((InputHandler.KeyReleased(Keys.Space) ||
                     InputHandler.KeyReleased(Keys.Enter) ||
                     (InputHandler.CheckMouseReleased(MouseButton.Left) && mouseOver)))
                {
                    if (selected >= 0)
                    {
                        GameItem item = GamePlayScreen.Player.Backpack.GetItem(
                            GamePlayScreen.Player.Backpack.Items[selected].Item.Name);
                        GamePlayScreen.Player.Gold += item.Item.Price * 3 / 4;
                    }
                }
                break;

            case ShopStateType.Talk:
                if (InputHandler.KeyReleased(Keys.Space) ||
                    InputHandler.KeyReleased(Keys.Enter) ||
                    (InputHandler.CheckMouseReleased(MouseButton.Left) && scene.IsOver))
                {
                    if (scene.SelectedIndex == 0)
                    {
                        isFirst = true;
                        State   = ShopStateType.Buy;
                        //selected = -1;
                        return;
                    }

                    if (scene.SelectedIndex == 1)
                    {
                        isFirst = true;
                        State   = ShopStateType.Sell;
                        //selected = -1;
                        return;
                    }

                    if (scene.SelectedIndex == 2 && State == ShopStateType.Talk)
                    {
                        StateManager.PopState();
                    }
                }
                break;
            }

            if (InputHandler.CheckMouseReleased(MouseButton.Right) || InputHandler.KeyReleased(Keys.Escape))
            {
                switch (State)
                {
                case ShopStateType.Buy:
                case ShopStateType.Sell:
                    State = ShopStateType.Talk;
                    break;

                case ShopStateType.Talk:
                    StateManager.PopState();
                    break;
                }
            }
        }
 protected void RemoveHandler(InputHandler handler)
 {
     inputHandlers = inputHandlers.Where(h => h != handler).ToImmutableArray();
 }
Esempio n. 53
0
 /// <summary>
 /// Set the input handler once you can get an instance to it.
 /// </summary>
 /// <param name="inputHandler">The InputHandler to use to fire input events.</param>
 protected void setInputHandler(InputHandler inputHandler)
 {
     this.inputHandler = inputHandler;
 }
Esempio n. 54
0
        public CreateMapGuiScreen(InputHandler Input)
            : base(Input, false, true, false, false)
        {
            Label tlabel = new Label(Input);

            tlabel.Text = "title: ";
            tlabel.Size = 2;
            Controls.Add(tlabel);

            tlabel      = new Label(Input);
            tlabel.Text = "base: ";
            tlabel.Size = 2;
            Controls.Add(tlabel);

            tlabel      = new Label(Input);
            tlabel.Text = "mode: ";
            tlabel.Size = 2;
            Controls.Add(tlabel);

            tlabel      = new Label(Input);
            tlabel.Text = "width: ";
            tlabel.Size = 2;
            Controls.Add(tlabel);

            tlabel      = new Label(Input);
            tlabel.Text = "height: ";
            tlabel.Size = 2;
            Controls.Add(tlabel);

            _mapTitle           = new TextBox(Input);
            _mapTitle.MaxLength = 18;
            _mapTitle.Size      = 2;
            Controls.Add(_mapTitle);

            _base = new ComboBox(Input);
            _base.Items.Add(Art.GRAPHICS[0, 2]);
            _base.Items.Add(Art.GRAPHICS[0, 4]);
            _base.Items.Add(Art.GRAPHICS[0, 6]);
            _base.Items.Add(Art.GRAPHICS[0, 5]);
            _base.Items.Add(Art.GRAPHICS[0, 3]);
            _base.Items.Add(Art.GRAPHICS[1, 4]);
            Controls.Add(_base);

            _mapMode = new ComboBox(Input);
            _mapMode.Items.Add(Art.GRAPHICS[23, 19]);
            _mapMode.Items.Add(Art.GRAPHICS[24, 19]);
            _mapMode.Items.Add(Art.GRAPHICS[25, 19]);
            Controls.Add(_mapMode);


            _width          = new NumericUpDown(Input);
            _width.Value    = 20;
            _width.MinValue = 20;
            _width.MaxValue = 120;
            Controls.Add(_width);

            _height          = new NumericUpDown(Input);
            _height.Value    = 20;
            _height.MinValue = 20;
            _height.MaxValue = 120;
            Controls.Add(_height);

            _mapTitle.IsFocused = true;

            _cursor      = new Label(Input);
            _cursor.Text = ">";
            _cursor.Size = 2;
            Controls.Add(_cursor);

            Update();
        }
 public void Init(InputHandler inputHandler, Weapon weapon, Animator animatorIK)
 {
     _inputHandler = inputHandler;
     _weapon       = weapon;
     _animatorIK   = animatorIK;
 }
Esempio n. 56
0
 // Use this for initialization
 void Start()
 {
     thisCharacter = GetComponent <CharacterMovement>();
     thisInput     = FindObjectOfType <InputHandler>();
 }
Esempio n. 57
0
        public override void Initialize()
        {
            base.Initialize();

            InputHandler = (InputHandler)Game.Services.GetService(typeof(InputHandler));
        }
Esempio n. 58
0
        public static void Revive(bool manual = false)
        {
            try
            {
                if (GUI.isPxgActive() == false)
                {
                    AutoItX.WinActivate(Addresses.PxgClientName);
                }

                if (GUI.PokeballPosition.X == 0 || GUI.PokeballPosition.Y == 0 || GUI.PokeballPosition.IsEmpty)
                {
                    if (Settings.Debug)
                    {
                        Settings.DebugText += "\n Pokeball position not set for reviving";
                    }
                    Console.WriteLine("Pokeball position not set for reviving");
                    Reviving = false;
                    return;
                }

                Reviving              = true;
                ReviveCooldown        = true;
                Cavebot.Enabled       = false;
                CavebotAttack.Enabled = false;
                if (Settings.Debug)
                {
                    Settings.DebugText += "\n Will Revive";
                }

                /////////////////////////
                if (manual || HP > 0)
                {
                    PutIn();
                }

                InputHandler.BlockUserInput(true);

                InputHandler.SendKeys(new string[] { AutoReviveHotkey }, 15);
                AutoItX.Sleep(15);
                InputHandler.MouseClick("left", GUI.PokeballPosition.X, GUI.PokeballPosition.Y);
                Settings.DebugText += "Run Revive";
                AutoItX.Sleep(100);
                PutOut();

                InputHandler.BlockUserInput(false);

                foreach (PokemonSpell spell in Pokemon.PokemonSpells)
                {
                    spell.Available = true;
                }
                if (HP > AutoReviveHP)
                {
                    Task.Run(async() => { await Task.Delay(2000); ReviveCooldown = false; });
                }
                else
                {
                    ReviveCooldown = false;
                }

                Reviving              = false;
                Cavebot.Enabled       = true;
                CavebotAttack.Enabled = true;
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error: Revive: " + ex.Message);
            }
        }
Esempio n. 59
0
        public TitleScreen(IViewportProvider viewport, GameStateManager manager, SoundEffect select, SoundEffect choose, InputHandler inputHandler)
            : base(manager)
        {
            this.viewport     = viewport;
            this.select       = select;
            this.choose       = choose;
            this.inputHandler = inputHandler;

            _menuText        = new string[] { "Start", "Shop", "Options", "Exit" };
            _menuDescription = new string[] {
                "Playing game with only one player",
                "Get new abilities to crush more enemies",
                "You can change inputs here",
                "Warning: I've never tested this button !",
            };

            _menuIndex = 0;
        }
Esempio n. 60
0
 private void Awake()
 {
     input  = InputHandler.Instance;
     rgb    = this.gameObject.GetComponent <Rigidbody2D>();
     collid = this.gameObject.GetComponent <Collider2D>();
 }