Пример #1
0
	/// <summary>
	/// Initialize singleton
	/// </summary>
	void Awake()
	{
		if (use != null) Destroy(use.gameObject);
		use = this;
		MessengerAM.Listen("www", this);
//		Messenger.AddListener("Clear Current Tiles", ClearTileSelectionCount);  //broadcast location: PlayerAction
	}
Пример #2
0
	void Start(){
		GameObject gm = GameObject.Find ("GameManager");
		gameManager = gm.GetComponent<CandyWizardGameManager>();
		input = gm.GetComponent<InputManager>();
		
		spawnPosition = transform.position;
	}
Пример #3
0
 public LoseState(DwarfGame game, GameStateManager stateManager, PlayState play)
     : base(game, "EconomyState", stateManager)
 {
     Input = new InputManager();
     PlayState = play;
     EnableScreensaver = false;
 }
    // Update is called once per frame
    void Update()
    {
        inputManager = InputManager.getCurrentInputManager();

        //Do not search for input if max players are registered
        if (inputManager.playerControls.Count == InputManager.MAX_NUMBER_OF_PLAYERS)
        {
            return;
        }

        //Loop over each unregistered input and check if a button is pressed
        unregisteredInputs.ForEach(input =>
        {
            if (input.getActionPressDown() ||
            input.getHorizontalAxis() != 0f ||
            input.getVerticalAxis() != 0f)
            {
                inputManager.assignPlayerInput(input);
            }
        });

        //Remove all player assigned input from unregistered input
        var assignedInputs = inputManager.playerControls.Values.ToList();
        assignedInputs.ForEach(input =>
        {
            unregisteredInputs.Remove(input);
            unregisteredInputsName.Remove(input.getName());
        });
    }
Пример #5
0
 // Use this for initialization
 void Start()
 {
     status = GetComponent<CharacterStatus>();
     charaAnimation = GetComponent<CharaAnimation>();
     inputManager = FindObjectOfType<InputManager>();
     gameRuleCtrl = FindObjectOfType<GameRuleCtrl>();
 }
Пример #6
0
	void Awake() {
		if(instance == null) {
			instance = this;
		} else {
			Destroy(this.gameObject);
		}
	}
Пример #7
0
        public GwenInput(InputManager inputManager)
        {
            this.inputManager = inputManager;

            canvas = null;
            mouseX = 0;
            mouseY = 0;
            m_AltGr = false;

            mouse = inputManager.Mouse;
            if (mouse != null)
            {
                mouse.MouseMove += ProcessMouseMove;
                mouse.MouseDrag += ProcessMouseDrag;
                mouse.MouseButtonPress += ProcessMouseButtonPressed;
                mouse.MouseButtonRelease += ProcessMouseButtonReleased;
                mouse.MouseWheelMove += ProcessMouseWheel;
            }

            keyboard = inputManager.Keyboard;
            if (keyboard != null)
            {
                keyboard.KeyPress += ProcessKeyDown;
                keyboard.KeyRelease += ProcessKeyUp;
                keyboard.KeyText += ProcessText;
            }
        }
Пример #8
0
        /// <summary>
        ///   Override this method to catch input events and act on the camera
        /// </summary>
        /// <param name = "input">The current input instance</param>
        protected override void UpdateInput(InputManager input)
        {
            var player = input.PlayerOne;

            Position += new Vector2(-player.ThumbSticks.LeftStick.X * Speed, player.ThumbSticks.LeftStick.Y * Speed);
            Distance += -player.ThumbSticks.RightStick.Y*Speed;
        }
Пример #9
0
    static void Init()
    {
        EditorWindow.GetWindow(typeof(IM_Manager));
        headTexture = Resources.Load<Texture>("EditorWindowTextures/headTexture");
        skypeTexture = Resources.Load<Texture>("EditorWindowTextures/skype-icon");
        emailTexture = Resources.Load<Texture>("EditorWindowTextures/email-icon");
        folderIcon = Resources.Load<Texture>("EditorWindowTextures/folder-icon");

        Object itemDatabase = Resources.Load("ItemDatabase");
        if (itemDatabase == null)
            inventoryItemList = CreateItemDatabase.createItemDatabase();
        else
            inventoryItemList = (ItemDataBaseList)Resources.Load("ItemDatabase");

        Object attributeDatabase = Resources.Load("AttributeDatabase");
        if (attributeDatabase == null)
            itemAttributeList = CreateAttributeDatabase.createItemAttributeDatabase();
        else
            itemAttributeList = (ItemAttributeList)Resources.Load("AttributeDatabase");

        Object inputManager = Resources.Load("InputManager");
        if (inputManager == null)
            inputManagerDatabase = CreateInputManager.createInputManager();
        else
            inputManagerDatabase = (InputManager)Resources.Load("InputManager");
    }
Пример #10
0
 public HeroState(FSM fsm)
     : base(fsm)
 {
     Hero = (HeroMotion)fsm;
     animator = gameObject.GetComponent<Animator>();
     InputManager = gameObject.GetComponent<InputManager>();
 }
Пример #11
0
	/// <summary>
	/// Unity method.
	/// Awake this instance.
	/// </summary>
	void Awake()
	{
		if (instance == null) {
			instance = this;
			createdInstance = true;
		}
		else {
			Debug.LogWarning("Input Manager already exists. Destroying this instance: " + name);
			Destroy(this);
		}
		
		cachedInputWrapper = InputWrapper.Instance;
		
		cachedInputWrapper.OnTapBegan += OnTapBegan;
		cachedInputWrapper.OnTapEnded += OnTapEnded;
		cachedInputWrapper.OnSwipeLeftRight += OnSwipeLeftRight;
		cachedInputWrapper.OnSwipeRightLeft += OnSwipeRightLeft;
		
		if (inputCameras == null) {
			inputCameras = new List<Camera>();
		}
		
		if (modalStack == null) {
			modalStack = new List<ModalItem>();
		}
	}
Пример #12
0
 // Use this for initialization
 void Start()
 {
     audioSource = GetComponent<AudioSource>();
     audioSource.clip = audioClip;
     flag = true;
     inputManager = FindObjectOfType<InputManager>();
 }
    public void Start()
    {
        //Grab mainObject prefab to access managers effectively
        mainObject = GameObject.FindGameObjectsWithTag("MainObject")[0];
        if (GameObject.FindGameObjectsWithTag("MainObject").Length > 1)
        {
            GameObject[] mainObjectList = GameObject.FindGameObjectsWithTag("MainObject");
            for (int i = 0; i < mainObjectList.Length; ++i)
            {
                if (mainObjectList[i].GetComponent<GameStateManager>().objectSaved)
                    mainObject = mainObjectList[i];
            }
        }

        // Notice, these are attached to the MainObject
        gameStateManagerRef = mainObject.GetComponent<GameStateManager>();
        animationManagerRef = gameStateManagerRef.GetAnimationManager();
        inputManagerRef = gameStateManagerRef.GetInputManager();
        worldCollisionRef = gameStateManagerRef.GetWorldCollision();

        // This script is attached to the player, so we use 'gameObject' here
        controllerRef = gameObject.GetComponent<TWCharacterController>();

        paperObject = GameObject.FindGameObjectWithTag("background");
    }
 // Update is called once per frame
 void Update()
 {
     if(inpManRef == null) inpManRef = gameStateManagerRef.GetInputManager();
     if(worldCollisionRef == null) worldCollisionRef = gameStateManagerRef.GetWorldCollision();
     if(inpManRef.foldMode) gameObject.renderer.material.color = new Color(0.0f, 0.0f, 0.0f);
     else gameObject.renderer.material.color = new Color(1.0f, 1.0f, 1.0f);
     // if the finger is within the bounds of this object
     #if UNITY_IPHONE
     if(worldCollisionRef.PointInsideObject(gameObject,
     gameStateManagerRef.GetTouchController().GetLastFingerPosition())
     #endif
     #if UNITY_ANDROID
     if(worldCollisionRef.PointInsideObject(gameObject,
     gameStateManagerRef.GetTouchController().GetLastFingerPosition())
     #endif
     #if UNITY_STANDALONE
     if(Input.GetMouseButtonDown(0) &&  (worldCollisionRef.PointInsideObject(gameObject, Input.mousePosition))
     #endif
     && !inpManRef.tearManagerRef.PlayerCurrentlyTearing &&
     !inpManRef.foldRef.currentlyFolding) /*&&
     // not performing a tear or a fold
     !gameStateManagerRef.GetInputManager().GetFingerGesture().Equals(InputManager.FingerGesture.TEAR) &&
     !gameStateManagerRef.GetInputManager().GetFingerGesture().Equals(InputManager.FingerGesture.FOLD)*/
     {
         inpManRef.moveMode = false;
         inpManRef.foldMode = true;
         inpManRef.tearMode = false;
         gameObject.renderer.material.color = new Color(0.0f, 0.0f, 0.0f);
     }
 }
Пример #15
0
    void Awake()
    {
        input = GetComponent<InputManager>();

        Cursor.visible = false;
        paused = false;
    }
Пример #16
0
        public BetaMouseMath()
        {
            this.varManager = VarManager.Instance;
            this.inputManager = InputManager.Instance;
            this.gamesManager = BetaGamesManager.Instance;

            this.varManager.GetVar(VarManager.Names.Speed, out m_speed);
            this.varManager.GetVar(VarManager.Names.Speed2, out m_speed2);
            this.varManager.GetVar(VarManager.Names.Speed3, out m_speed3);
            this.varManager.GetVar(VarManager.Names.Speed4, out m_speed4);
            this.varManager.GetVar(VarManager.Names.Accel, out m_accel);
            this.varManager.GetVar(VarManager.Names.Accel2, out m_accel2);
            this.varManager.GetVar(VarManager.Names.Accel3, out m_accel3);
            this.varManager.GetVar(VarManager.Names.Accel4, out m_accel4);
            this.varManager.GetVar(VarManager.Names.Sensitivity1, out m_sensitivity1);
            this.varManager.GetVar(VarManager.Names.Sensitivity2, out m_sensitivity2);
            this.varManager.GetVar(VarManager.Names.AltSens, out m_altSens);
            this.varManager.GetVar(VarManager.Names.AltSens2, out m_altSens2);
            this.varManager.GetVar(VarManager.Names.AltSens3, out m_altSens3);
            this.varManager.GetVar(VarManager.Names.Deadzone, out m_deadzone);
            this.varManager.GetVar(VarManager.Names.YXRatio, out m_yxratio);
            this.varManager.GetVar(VarManager.Names.TransExponent1, out m_transExp1);
            this.varManager.GetVar(VarManager.Names.Smoothness, out m_smoothness);
            this.varManager.GetVar(VarManager.Names.Rate, out m_rate);
            this.varManager.GetVar(VarManager.Names.AutoAnalogDisconnect, out m_autoAnalogDisconnect);
            this.varManager.GetVar(VarManager.Names.CircularDeadzone, out m_circularDeadzone);
            this.varManager.GetVar(VarManager.Names.UseXimApiMouseMath, out m_useXimApiMouseMath);
            this.varManager.GetVar(VarManager.Names.DiagonalDampen, out m_diagonalDampen);
            this.varManager.GetVar(VarManager.Names.CurrentGame, out m_currentGame);
            this.varManager.GetVar(VarManager.Names.MouseStickX, out m_mouseStickX);
            this.varManager.GetVar(VarManager.Names.MouseStickY, out m_mouseStickY);
            this.varManager.GetVar(VarManager.Names.InvertY, out m_inverty);
            this.varManager.GetVar(VarManager.Names.MouseDPI, out m_mouseDpi);
        }
Пример #17
0
 public Screen(ScreenManager manager)
 {
     this.manager = manager;
     this.loadComplete = false;
     this.camera = new Camera2D(manager.ViewManager.Width, manager.ViewManager.Height);
     this.inputManager = new InputManager();
 }
Пример #18
0
        public override void OnBodiesSelected(List<Body> bodies, InputManager.MouseButton button)
        {
            List<Body> resourcesPickedByMouse = ComponentManager.FilterComponentsWithTag("Resource", bodies);
            List<Task> assignments = new List<Task>();
            foreach(Body resource in resourcesPickedByMouse.Where(resource => resource.IsActive && resource.IsVisible && resource.Parent == PlayState.ComponentManager.RootComponent))
            {
                if (!resource.IsVisible || resource.IsAboveCullPlane) continue;
                Drawer3D.DrawBox(resource.BoundingBox, Color.LightGoldenrodYellow, 0.05f, true);

                if(button == InputManager.MouseButton.Left)
                {
                    Player.Faction.AddGatherDesignation(resource);

                    assignments.Add(new GatherItemTask(resource));
                }
                else
                {
                    if(!Player.Faction.GatherDesignations.Contains(resource))
                    {
                        continue;
                    }

                    Player.Faction.GatherDesignations.Remove(resource);
                }
            }

            TaskManager.AssignTasks(assignments, Faction.FilterMinionsWithCapability(PlayState.Master.SelectedMinions, GameMaster.ToolMode.Gather));
        }
Пример #19
0
 // Use this for initialization
 void Awake()
 {
     if (Instance != null) {
         Debug.LogError ("TOO MANY INPUT MANAGERS");
     }
     Instance = this;
 }
Пример #20
0
    void Start()
    {
        if (gManager == this)
        {
            isPaused = false;
            iManager = new InputManager(0.1f, 0.2f); // It could be helpful, I guess.
            tagged_objects = GameObject.FindGameObjectsWithTag("Scene_Object");
            scene_objects = new ISceneObject[tagged_objects.Length];
            iManager.Initialize();
            // Initialize the list of scene objects, all of which have ONE ISceneObject component.
            for (int i = 0; i < tagged_objects.Length; i++)
            {
                scene_objects[i] = tagged_objects[i].GetComponent<ISceneObject>(); // Grab all of those scene objects!
            }

            // Initialize all scene objects.
            for (int j = 0; j < scene_objects.Length; j++)
            {
                scene_objects[j].Initialize();
            }
            levelDictionary = new Dictionary<GameState, string>() { { GameState.TLEVELONE, "GMLevel1" },
                                                                    { GameState.TLEVELTWO, "GMLevel2" },
                {GameState.LEVELONE, "Level1" },
                {GameState.LEVELTWO, "Level2" },
                { GameState.LEVELTHREE, "Level3"},
                {GameState.LEVELFOUR, "Level4" } };
            // This will break on regular levels, handle regular levels separately.
            GameManager.gState = levelDictionary.FirstOrDefault(x => x.Value == _testLevelPrefix + SceneManager.GetActiveScene().name).Key;
            if(GameManager.m_Camera != null)
            {
                transform.Find("PauseScreen").gameObject.GetComponent<Canvas>().worldCamera = GameManager.m_Camera;
            }
        }
    }
Пример #21
0
        public OperationCronos()
        {
            graphics = new GraphicsDeviceManager(this);
            graphics.PreferredBackBufferWidth = 1024;
            graphics.PreferredBackBufferHeight = 768;
            Services.AddService(typeof(GraphicsDeviceManager), graphics);
            Content.RootDirectory = "Content";
            debug = new Debug(this);
            IsMouseVisible = false;
            gameStarted = false;

            //hides the Form's ControlBox
            Form MyGameForm = (Form)Form.FromHandle(this.Window.Handle);
            MyGameForm.ControlBox = false;
            MyGameForm.Text = "Operation Cronos";
            //---------------------------

            inputManager = new InputManager(this);

            displayManager = new DisplayManager(this);

            ioManager = new IOManager(this);

            gameManager = new GameManager(this);

            profileManager = new ProfileManager(this);

            soundManager = new SoundManager(this);
        }
Пример #22
0
 public CharacterController(DefaultCamera camera, InputManager inputManager, float mass)
     : base(mass, PhysicsWorld.PhysicsShape.ConvexMesh)
 {
     this.camera = camera;
     this.inputManager = inputManager;
     camera.KeysEnabled = false;
 }
        public Personnage(Rectangle winsize, Vector2 position)
            : base(winsize, position, 140, 190, @"game\perso", 15, 4)
        {
            _graphicalBounds = new GraphicalBounds<CharacterActions>(new Dictionary<CharacterActions, Rectangle>());
            _graphicalBounds.set(CharacterActions.WalkRight, 3, 6, 15);
            _graphicalBounds.set(CharacterActions.WalkLeft, 18, 21, 30);
            _graphicalBounds.set(CharacterActions.StandRight, 1, 1, 2, 4);
            _graphicalBounds.set(CharacterActions.StandLeft, 16, 16, 17, 4);
            _graphicalBounds.set(CharacterActions.JumpRight, 31, 31, 35);
            _graphicalBounds.set(CharacterActions.JumpLeft, 36, 36, 40);
            _graphicalBounds.set(CharacterActions.Attack1Right, 41, 41, 49, 35);
            _graphicalBounds.set(CharacterActions.Attack1Left, 50, 50, 58, 35);
            _graphicalBounds.set(CharacterActions.AttackStunRight, 1, 1, 2, 4);
            _graphicalBounds.set(CharacterActions.AttackStunLeft, 16, 16, 17, 4);
            _graphicalBounds.set(CharacterActions.ReceiveAttackRight, 60, 60, 60);
            _graphicalBounds.set(CharacterActions.ReceiveAttackLeft, 59, 59, 59);
            Action = CharacterActions.StandRight;
            _physics.MaxHeight = 400;
            _physics.TimeOnFlat = 500;
            _inputManager = new InputManager<KeysActions, Keys>();
            Weapon = new Weapon(winsize, @"game/weapon", _sprite.Lignes, _sprite.Colonnes, _sprite.Position.Width, _sprite.Position.Height);
            InitKeys();
            actualizeSpriteGraphicalBounds();
            actualizeSpritePosition();
            Jump();
            Mana = 1;
            _experience = new ExperienceCounter(ExperienceCounter.Growth.Cuadratic);

            AddAttack(CharacterActions.AttackStunLeft, new Attack(_windowSize, new AnimatedSprite(new Rectangle(0, 0, 400, 400), _windowSize, "sprites/expl_spread_6x6", 6, 6, 30, 1, 32, 1, true), 1500, 0.001f, 3000, 1000, 0.3f));
            AddAttack(CharacterActions.AttackStunRight, new Attack(_windowSize, new AnimatedSprite(new Rectangle(0, 0, 400, 400), _windowSize, "sprites/expl_spread_6x6", 6, 6, 30, 1, 32, 1, true), 1500, 0.001f, 3000, 1000, 0.3f));
            AddAttack(CharacterActions.Attack1Right, new Attack(_windowSize, new AnimatedSprite(new Rectangle(0, 0, 10, 10), _windowSize, "general/vide"), 50, 0.1f, 500, 400, 0.1f));
            AddAttack(CharacterActions.Attack1Left, new Attack(_windowSize, new AnimatedSprite(new Rectangle(0, 0, 10, 10), _windowSize, "general/vide"), 50, 0.1f, 500, 400, 0.1f));
        }
Пример #24
0
	public List<Button> getRandomCombo(int comboLength, InputManager.Side side) {
		List<Button> aList = new List<Button> ();
		for (int i = 0; i < comboLength; i++) {
			aList.Add (getRandomButton (side));
		}
		return aList;
	}
Пример #25
0
        public override void OnBodiesSelected(List<Body> bodies, InputManager.MouseButton button)
        {
            List<Body> treesPickedByMouse = ComponentManager.FilterComponentsWithTag("Vegetation", bodies);

            foreach (Body tree in treesPickedByMouse)
            {
                if (!tree.IsVisible || tree.IsAboveCullPlane) continue;

                Drawer3D.DrawBox(tree.BoundingBox, Color.LightGreen, 0.1f, false);
                if (button == InputManager.MouseButton.Left)
                {
                    if (!Player.Faction.ChopDesignations.Contains(tree))
                    {
                        Player.Faction.ChopDesignations.Add(tree);

                        foreach(CreatureAI creature in Player.Faction.SelectedMinions)
                        {
                            creature.Tasks.Add(new KillEntityTask(tree, KillEntityTask.KillType.Chop) { Priority = Task.PriorityType.Low});
                        }
                    }
                }
                else if (button == InputManager.MouseButton.Right)
                {
                    if (Player.Faction.ChopDesignations.Contains(tree))
                    {
                        Player.Faction.ChopDesignations.Remove(tree);
                    }
                }
            }
        }
Пример #26
0
        public override void LoadContent(ContentManager Content, InputManager inputManager)
        {
            base.LoadContent(Content, inputManager);
            if (font== null)
                font = content.Load<SpriteFont>("Font1");

            imageNumber = 0;
            fileManager = new FileManager();
            fade = new List<FadeAnimation>();
            images = new List<Texture2D>();

            fileManager.LoadContent("Load/Splash.cme", attributes, contents);

            for (int i = 0; i < attributes.Count; i++)
            {
                for (int j = 0; j < attributes[i].Count; j++)
                {
                    switch (attributes[i][j])
                    {
                        case "Image":
                            images.Add(content.Load<Texture2D>(contents[i][j]));
                            fade.Add(new FadeAnimation());
                            break;
                    }
                }
            }
            for (int i = 0; i < fade.Count; i++)
            {
                fade[i].LoadContent(content, images[i], "", new Vector2(80,60));
                fade[i].Scale = 1.25f;
                fade[i].IsActive = true;
            }
        }
Пример #27
0
 void Start()
 {
     status = GetComponent<CharStatus> ();
     jump = GetComponent<CharJump> ();
     rigidBody2D = GetComponent<Rigidbody2D> ();
     input = GameObject.Find ("InputManager").GetComponent<InputManager> ();
 }
	private PlayerAnimMachine aniMachine;		//our animation controller helper



	void Awake()
	{
		inputManage = GameObject.FindObjectOfType<InputManager>();

		//check if one or more classes that we need exist. Case not tell us through an error.

		if(inputManage == null)
		{
			throw new UnassignedReferenceException("inputManage as InputManager is null. "); //component has been not assigned at Inspector tab.
		}

		aniMachine = FindObjectOfType<PlayerAnimMachine>();

		if(aniMachine == null)
		{
			throw new UnassignedReferenceException("aniMachine as PlayerAnimMachine is null."); //component has been not assigned at Inspector tab.
		}


		rigidBod2d = this.GetComponent<Rigidbody2D>();

		// i prefer occupy memory instead cpu to not slow down using garbage collector.
		//Look left and Look right are setter once to use less cpu.
		lookLeft = new Vector3(-this.gameObject.transform.localScale.x
		                       ,this.gameObject.transform.localScale.y
		                       ,this.gameObject.transform.localScale.z);

		lookRight = new Vector3(this.gameObject.transform.localScale.x
		                        ,this.gameObject.transform.localScale.y
		                        ,this.gameObject.transform.localScale.z);
	}
Пример #29
0
	Button getRandomButton(InputManager.Side side) {
		int a = Random.Range (0, 4);
		if (a == 0) {
			if (side == InputManager.Side.Left) {
				return Button.upButton;
			} else {
				return Button.yellowButton;
			}
		} else if (a == 1) {
			if (side == InputManager.Side.Left) {
				return Button.leftButton;
			} else {
				return Button.redButton;
			}
		} else if (a == 2) {
			if (side == InputManager.Side.Left) {
				return Button.downButton;
			} else {
				return Button.blueButton;
			}
		} else {
			if (side == InputManager.Side.Left) {
				return Button.rightButton;
			} else {
				return Button.greenButton;
			}
		}
	}
Пример #30
0
    void Awake()
    {
        if (sGame)
        {
            // NO DUPES ALLOWED (can happen if we reload the Scene with this on the side)
            UnityEngine.Object.DestroyImmediate(gameObject);
            return;
        }
        sGame = this;
        mInputManager = new InputManager();
        mInputManager.AddInputListener("flap", this);
        mScreenListeners = new List<IScreenListener>();
        mCachedScreenWidth = Screen.width;
        mCachedScreenHeight = Screen.height;

        mWorldStateListeners = new List<IWorldStateListener>();

        mLevelManager = new LevelManager();
        mLevelManager.TurretPrefab = TurretPrefab;

        mBulletManager = new BulletManager();


        // Sometimes the listeners add themselves, sometimes we add the listeners.
        AddWorldStateListener(mLevelManager);
        AddWorldStateListener(mBulletManager);
        AddScreenListener(mBulletManager);
        mLevelManager.AddSpeedListener(mBulletManager);


        // mCachedResolution = Screen.currentResolution;
    }
Пример #31
0
 private bool NoInputsDown()
 {
     return(InputManager.GetAllKeysDown().Length == 0);
 }
Пример #32
0
 private void press(Key key)
 {
     InputManager.PressKey(key);
     InputManager.ReleaseKey(key);
 }
Пример #33
0
        public void HandleInput(InputManager inputManager, ITimeline time)
        {

        }
Пример #34
0
 public void TestCursorInCentre()
 {
     AddStep("move mouse to centre", () => InputManager.MoveMouseTo(grid.ToScreenSpace(grid_position)));
     assertSnappedDistance((float)beat_length);
 }
Пример #35
0
 protected override void LoadComplete()
 {
     base.LoadComplete();
     inputManager = GetContainingInputManager();
 }
        public void TestNestedScrolling(Direction outer, Direction inner)
        {
            BasicScrollContainer horizontalScroll = null;
            BasicScrollContainer verticalScroll   = null;

            AddStep("create scroll containers", () =>
            {
                BasicScrollContainer outerScroll;
                BasicScrollContainer innerScroll;

                Child = outerScroll = new BasicScrollContainer(outer)
                {
                    Anchor   = Anchor.Centre,
                    Origin   = Anchor.Centre,
                    Size     = new Vector2(500),
                    Children = new Drawable[]
                    {
                        new Box
                        {
                            Size   = new Vector2(500f),
                            Colour = FrameworkColour.Yellow,
                        },
                        innerScroll = new BasicScrollContainer(inner)
                        {
                            Anchor = Anchor.Centre,
                            Origin = Anchor.Centre,
                            Size   = new Vector2(250, 250),
                            Child  = new Box
                            {
                                Size   = new Vector2(250, 250),
                                Colour = FrameworkColour.Green,
                            },
                        }
                    }
                };

                horizontalScroll = outer == Direction.Horizontal ? outerScroll : innerScroll;
                verticalScroll   = outer == Direction.Vertical ? outerScroll : innerScroll;
            });

            AddStep("drag vertically", () =>
            {
                InputManager.MoveMouseTo(verticalScroll);
                InputManager.PressButton(MouseButton.Left);
                InputManager.MoveMouseTo(verticalScroll, new Vector2(0, -50));
            });
            AddAssert("vertical container scrolled only", () => checkScrollCurrent(verticalScroll, horizontalScroll));
            AddStep("reset vertical scroll", () =>
            {
                InputManager.ReleaseButton(MouseButton.Left);
                verticalScroll.ScrollToStart(false, true);
            });

            AddStep("drag horizontally", () =>
            {
                InputManager.MoveMouseTo(horizontalScroll);
                InputManager.PressButton(MouseButton.Left);
                InputManager.MoveMouseTo(horizontalScroll, new Vector2(-50, 0));
            });
            AddAssert("horizontal container scrolled only", () => checkScrollCurrent(horizontalScroll, verticalScroll));
            AddStep("reset horizontal scroll", () =>
            {
                InputManager.ReleaseButton(MouseButton.Left);
                horizontalScroll.ScrollToStart(false, true);
            });

            // if the inner is a horizontal scroll container, it'll absorb input either way,
            // as vertical scrolls translate to horizontal in a horizontal scroll container.
            if (inner != Direction.Horizontal)
            {
                AddStep("scroll vertically", () => InputManager.ScrollVerticalBy(-50));
                AddAssert("vertical container scrolled only", () => checkScrollCurrent(verticalScroll, horizontalScroll));
                AddStep("reset vertical scroll", () => verticalScroll.ScrollToStart(false));
            }

            AddStep("scroll horizontally", () => InputManager.ScrollHorizontalBy(-50));
            AddAssert("horizontal container scrolled only", () => checkScrollCurrent(horizontalScroll, verticalScroll));
            AddStep("reset horizontal scroll", () => horizontalScroll.ScrollToStart(false));
Пример #37
0
 public void TestPauseResume()
 {
     AddStep("move cursor outside", () => InputManager.MoveMouseTo(Player.ScreenSpaceDrawQuad.TopLeft - new Vector2(10)));
     pauseAndConfirm();
     resumeAndConfirm();
 }
Пример #38
0
    //marker
    #endregion

    #region Awake Ship Setting
    void Awake()
    {
        invitedShips = new List <Ship>();
        startHeight  = transform.position.y;
        if (GameObject.FindObjectOfType <ComradManager> ())
        {
            theUniterShip = GameObject.FindObjectOfType <ComradManager> ().theUniterShip;
        }
        else
        {
            Destroy(gameObject);
        }

        comradManager = theUniterShip.GetComradManager;
        if (shipType == ShipType.TheUniter)
        {
            #region TheUniterShip values
            isComrad        = true;
            inputManager    = Component.FindObjectOfType <InputManager>();
            cameraThrusters = Component.FindObjectOfType <Camera_Thrusters>();
            uniterRespawner = Component.FindObjectOfType <UniterRespawner>();
            if (uniterRespawner)
            {
                uniterRespawner.SetUniter(this);
            }
            rotationSpeed      = 0.05f;
            conversionTime     = 5f;
            maxElevationHeight = 6f;

            Ship[] allShips = GameObject.FindObjectsOfType <Ship>();
            foreach (Ship ship in allShips)
            {
                ship.GetTheUniterShip = this;
                ship.GetComradManager = comradManager;
                ship.ShotDirector     = shotDirector;
                ship.MedicalBayHQ     = medicalBayHQ;
            }
            #endregion
        }
        else if (shipType == ShipType.Normal)
        {
            #region NormalShip values
            rotationSpeed      = 0.1f;
            conversionTime     = 1f;
            maxElevationHeight = 2f;
            #endregion
        }
        else if (shipType == ShipType.Alpha)
        {
            #region AlphaShip values
            rotationSpeed      = 0.07f;
            conversionTime     = 2f;
            maxElevationHeight = 4f;
            #endregion
        }
        else if (shipType == ShipType.Bravo)
        {
            #region BravoShip values
            rotationSpeed      = 0.03f;
            conversionTime     = 3f;
            maxElevationHeight = 5f;
            #endregion
        }
        elevationForce    = 5f;
        maxElevationSpeed = 5f;
    }
Пример #39
0
 public StoryChooseState(StorySM stateMachine, InputManager input, StoryChoiceController decisionController)
 {
     _stateMachine       = stateMachine;
     _input              = input;
     _decisionController = decisionController;
 }
Пример #40
0
 public void TestCursorBeforeMovementPoint()
 {
     AddStep("move mouse to just before movement point", () => InputManager.MoveMouseTo(grid.ToScreenSpace(grid_position + new Vector2((float)beat_length, 0) * 1.49f)));
     assertSnappedDistance((float)beat_length);
 }
Пример #41
0
    public string GetText()
    {
        KeyCode c = InputManager.GetInput(InputName);

        return(RichText.InBold(GetDisplayName()) + " : " + c);
    }
Пример #42
0
 public void Reset()
 {
     InputManager.ResetInput(InputName);
     SetName();
 }
Пример #43
0
 public void TestAlwaysOpen()
 {
     AddStep("Click outside", () => InputManager.Click(MouseButton.Left));
     AddAssert("Check AlwaysOpen = true", () => Menus.GetSubMenu(0).State == MenuState.Open);
 }
Пример #44
0
 private bool AnyInputDown()
 {
     return(InputManager.GetAllKeysDown().Length > 0);
 }
        public override void HandleInput()
        {
            if (m_lockControls)
            {
                return;
            }

            if (m_settingKey)
            {
                if (InputManager.IsAnyButtonPressed() || InputManager.IsAnyKeyPressed())
                {
                    ChangeKey();
                }

                return;
            }

            int lastIndex = m_selectedEntryIndex;

            if (InputManager.IsNewlyPressed(InputFlags.PlayerUp1 | InputFlags.PlayerUp2))
            {
                SoundManager.PlaySound("frame_swap");
                m_selectedEntryIndex--;
            }
            else if (InputManager.IsNewlyPressed(InputFlags.PlayerDown1 | InputFlags.PlayerDown2))
            {
                SoundManager.PlaySound("frame_swap");
                m_selectedEntryIndex++;
            }

            if (m_selectedEntryIndex > m_buttonTitle.Count - 1)
            {
                m_selectedEntryIndex = 0;
            }
            else if (m_selectedEntryIndex < 0)
            {
                m_selectedEntryIndex = m_buttonTitle.Count - 1;
            }

            if (lastIndex != m_selectedEntryIndex)
            {
                m_selectedEntry.TextureColor = Color.White;
                m_selectedEntry = m_buttonTitle[m_selectedEntryIndex];
                m_selectedEntry.TextureColor = Color.Yellow;
            }

            if (InputManager.IsNewlyPressed(InputFlags.MenuConfirm1 | InputFlags.MenuConfirm2))
            {
                SoundManager.PlaySound("Option_Menu_Select");
                m_lockControls = true;

                if (m_selectedEntryIndex == m_controlKeys.Length - 1)
                {
                    var screenManager = Game.ScreenManager;
                    screenManager.DialogueScreen.SetDialogue("RestoreDefaultControlsWarning");
                    screenManager.DialogueScreen.SetDialogueChoice("ConfirmTest1");
                    screenManager.DialogueScreen.SetConfirmEndHandler(this, "RestoreControls");
                    screenManager.DialogueScreen.SetCancelEndHandler(this, "CancelRestoreControls");
                    screenManager.DisplayScreen(13, true, null);
                }
                else
                {
                    Tween.To(m_setKeyPlate, 0.3f, Back.EaseOut, "ScaleX", "1", "ScaleY", "1");
                    Tween.AddEndHandlerToLastTween(this, "SetKeyTrue");
                }
            }
            else if (InputManager.IsNewlyPressed(InputFlags.MenuCancel1 | InputFlags.MenuCancel2))
            {
                IsActive = false;
            }

            base.HandleInput();
        }
Пример #46
0
 public void TestHoverState()
 {
     AddAssert("Check submenu closed", () => Menus.GetSubMenu(1)?.State != MenuState.Open);
     AddStep("Hover item", () => InputManager.MoveMouseTo(Menus.GetMenuItems()[0]));
     AddAssert("Check item hovered", () => Menus.GetMenuItems()[0].IsHovered);
 }
Пример #47
0
 private void FixedUpdate()
 {
     InputManager.GetPlayerInputs(player);
 }
        private void ChangeKey()
        {
            Keys    keyPressed    = 0;
            Buttons buttonPressed = 0;

            if (InputManager.IsAnyKeyPressed())
            {
                keyPressed = InputManager.PressedKeys[0];
                if (InputSystem.InputReader.GetInputString(keyPressed, false, false, false).ToUpper() == "")
                {
                    return;
                }

                if (_disabledKeys.Contains(keyPressed))
                {
                    return;
                }

                if (keyPressed == Keys.Escape)
                {
                    Tween.To(m_setKeyPlate, 0.3f, Back.EaseIn, "ScaleX", "0", "ScaleY", "0");
                    m_settingKey = false;
                    return;
                }
            }
            else if (InputManager.IsAnyButtonPressed())
            {
                buttonPressed = InputManager.PressedButtons;
                if (buttonPressed == Buttons.Start || buttonPressed == Buttons.Back)
                {
                    return;
                }
            }

            SoundManager.PlaySound("Gen_Menu_Toggle");
            Tween.To(m_setKeyPlate, 0.3f, Back.EaseIn, "ScaleX", "0", "ScaleY", "0");
            m_settingKey = false;

            if (buttonPressed != 0)
            {
                InputManager.MapButton(buttonPressed, (InputKeys)m_controlKeys[m_selectedEntryIndex]);
                //var mapArr = InputManager.ButtonMap;
                //for (int keyIndex = 0; keyIndex < mapArr.Length; keyIndex++)
                //{
                //    bool isPlayerKey = !_menuKeyMap.Contains(keyIndex);
                //    if (isPlayerKey && mapArr[keyIndex] == buttonPressed)
                //        mapArr[keyIndex] = mapArr[m_controlKeys[m_selectedEntryIndex]];
                //}
                //mapArr[m_controlKeys[m_selectedEntryIndex]] = buttonPressed;
            }
            else if (keyPressed != 0)
            {
                InputManager.MapKey(keyPressed, (InputKeys)m_controlKeys[m_selectedEntryIndex]);
                //var mapArr = InputManager.KeyMap;
                //for (int keyIndex = 0; keyIndex < mapArr.Length; keyIndex++)
                //{
                //    bool isPlayerKey = !_menuKeyMap.Contains(keyIndex);
                //    if (isPlayerKey && mapArr[keyIndex] == keyPressed)
                //        mapArr[keyIndex] = mapArr[m_controlKeys[m_selectedEntryIndex]];
                //}
                //mapArr[m_controlKeys[m_selectedEntryIndex]] = keyPressed;
            }

            UpdateKeyBindings();
        }
Пример #49
0
    void Update()
    {
        if (isLocalPlayer)
        {
            hudManagerScript.SetCurrentAlumoonite(currentResources);
            DetectionArea();

            if (CanInteract())
            {
                if (InputManager.InteractionButton())
                {
                    if (boxInPossession)
                    {
                        CmdDropInventoryBox();
                    }
                    else
                    {
                        if (interactionItem != null)
                        {
                            if (interactionItem.CompareTag("InventoryBox"))
                            {
                                CmdPickInventoryBox(interactionItem.gameObject);
                            }
                            else
                            {
                                // interaccion con el objeto en cuestion
                                if (interactionItem.GetComponent <LunarModule>() && interactionItem.gameObject == myLunarModule)
                                {
                                    interactionItem.GetComponent <LunarModule>().Interaction();
                                }
                                if (interactionItem.CompareTag("MineralVein"))   // veta de mineral
                                {
                                    CmdMineMineral(interactionItem.gameObject);
                                }
                                if (interactionItem.CompareTag("MineralFragment"))   // mineral
                                {
                                    if (currentResources < 10)
                                    {
                                        CmdPickAlomoonite(interactionItem.gameObject);
                                    }
                                }
                            }
                        }
                    }
                }
                if (InputManager.ShootGunButton() && !boxInPossession)
                {
                    ShootLaser();
                }
                if (currentMines > 0 && InputManager.TrapButton())
                {
                    PlantBlackHoleMine();
                }
            }
        }

        playerInput.playerAnimator.SetBool("Shooting", Time.time < nextShootTime);
        playerInput.playerAnimator.SetBool("Carrying Box", boxInPossession);

        energy += Mathf.Clamp(Time.deltaTime * energyRegenPerSecond, 0, maxEnergy);
    }
Пример #50
0
 // Start is called before the first frame update
 void Start()
 {
     inputManager = InputManager.Instance;
     OnNext();
 }
Пример #51
0
 private void Update()
 {
     if (view != null && !view.IsMine)
     {
         return;
     }
     if (isHorse)
     {
         int Ordonate;
         if (InputManager.IsInputHorseHolding((int)InputHorse.HorseForward))
         {
             Ordonate = 1;
         }
         else
         {
             if (InputManager.IsInputHorseHolding((int)InputHorse.HorseBackward))
             {
                 Ordonate = -1;
             }
             else
             {
                 Ordonate = 0;
             }
         }
         int Abscissa;
         if (InputManager.IsInputHorseHolding((int)InputHorse.HorseLeft))
         {
             Abscissa = -1;
         }
         else
         {
             if (InputManager.IsInputHorseHolding((int)InputHorse.HorseRight))
             {
                 Abscissa = 1;
             }
             else
             {
                 Abscissa = 0;
             }
         }
         if (Abscissa != 0 || Ordonate != 0)
         {
             float CameraAngle = currentCamera.transform.rotation.eulerAngles.y;
             float Tan         = Mathf.Atan2((float)Ordonate, (float)Abscissa) * 57.29578f;
             Tan = -Tan + 90f;
             float direction = CameraAngle + Tan;
             targetDirection = direction;
         }
         else
         {
             targetDirection = -874f;
         }
         isAttackDown   = false;
         isAttackIIDown = false;
         if (targetDirection != -874f)
         {
             currentDirection = targetDirection;
         }
         float num5 = currentCamera.transform.rotation.eulerAngles.y - currentDirection;
         if (num5 >= 180f)
         {
             num5 -= 360f;
         }
         if (InputManager.IsInputHorseHolding((int)InputHorse.HorseJump))
         {
             isAttackDown = true;
         }
         isWALKDown = InputManager.IsInputHorseHolding((int)InputHorse.HorseWalk);
     }
     else
     {
         int Ordonate;
         if (InputManager.IsInputTitanHolding((int)InputTitan.TitanForward))
         {
             Ordonate = 1;
         }
         else if (InputManager.IsInputTitanHolding((int)InputTitan.TitanBackward))
         {
             Ordonate = -1;
         }
         else
         {
             Ordonate = 0;
         }
         int Abscissa;
         if (InputManager.IsInputTitanHolding((int)InputTitan.TitanLeft))
         {
             Abscissa = -1;
         }
         else if (InputManager.IsInputTitanHolding((int)InputTitan.TitanRight))
         {
             Abscissa = 1;
         }
         else
         {
             Abscissa = 0;
         }
         if (Abscissa != 0 || Ordonate != 0)
         {
             float CameraAngle = IN_GAME_MAIN_CAMERA.MainCamera.transform.rotation.eulerAngles.y;
             float Tan         = Mathf.Atan2((float)Ordonate, (float)Abscissa) * 57.29578f;
             Tan = -Tan + 90f;
             float Direction = CameraAngle + Tan;
             targetDirection = Direction;
         }
         else
         {
             targetDirection = -874f;
         }
         isAttackDown   = false;
         isJumpDown     = false;
         isAttackIIDown = false;
         isSuicide      = false;
         grabbackl      = false;
         grabbackr      = false;
         grabfrontl     = false;
         grabfrontr     = false;
         grabnapel      = false;
         grabnaper      = false;
         choptl         = false;
         chopr          = false;
         chopl          = false;
         choptr         = false;
         bite           = false;
         bitel          = false;
         biter          = false;
         cover          = false;
         sit            = false;
         if (targetDirection != -874f)
         {
             currentDirection = targetDirection;
         }
         float num5 = currentCamera.transform.rotation.eulerAngles.y - currentDirection;
         if (num5 >= 180f)
         {
             num5 -= 360f;
         }
         if (InputManager.IsInputTitan((int)InputTitan.TitanPunch))
         {
             isAttackDown = true;
         }
         if (InputManager.IsInputTitan((int)InputTitan.TitanSlam))
         {
             isAttackIIDown = true;
         }
         if (InputManager.IsInputTitan((int)InputTitan.TitanJump))
         {
             isJumpDown = true;
         }
         if (InputManager.IsInputTitan((int)InputTitan.TitanKill))
         {
             isSuicide = true;
         }
         if (InputManager.IsInputTitan((int)InputTitan.TitanCoverNape))
         {
             cover = true;
         }
         if (InputManager.IsInputTitan((int)InputTitan.TitanSit))
         {
             sit = true;
         }
         if (InputManager.IsInputTitan((int)InputTitan.TitanGrabFront) && num5 >= 0f)
         {
             grabfrontr = true;
         }
         if (InputManager.IsInputTitan((int)InputTitan.TitanGrabFront) && num5 < 0f)
         {
             grabfrontl = true;
         }
         if (InputManager.IsInputTitan((int)InputTitan.TitanGrabBack) && num5 >= 0f)
         {
             grabbackr = true;
         }
         if (InputManager.IsInputTitan((int)InputTitan.TitanGrabBack) && num5 < 0f)
         {
             grabbackl = true;
         }
         if (InputManager.IsInputTitan((int)InputTitan.TitanGrabNape) && num5 >= 0f)
         {
             grabnaper = true;
         }
         if (InputManager.IsInputTitan((int)InputTitan.TitanGrabNape) && num5 < 0f)
         {
             grabnapel = true;
         }
         if (InputManager.IsInputTitan((int)InputTitan.TitanSlap) && num5 >= 0f)
         {
             choptr = true;
         }
         if (InputManager.IsInputTitan((int)InputTitan.TitanSlap) && num5 < 0f)
         {
             choptl = true;
         }
         if (InputManager.IsInputTitan((int)InputTitan.TitanBite) && num5 > 7.5f)
         {
             biter = true;
         }
         if (InputManager.IsInputTitan((int)InputTitan.TitanBite) && num5 < -7.5f)
         {
             bitel = true;
         }
         if (InputManager.IsInputTitan((int)InputTitan.TitanBite) && num5 >= -7.5f && num5 <= 7.5f)
         {
             bite = true;
         }
         isWALKDown = InputManager.IsInputTitanHolding((int)InputTitan.TitanWalk);
     }
 }
Пример #52
0
 void Awake()
 {
     instance = this;
 }
Пример #53
0
        /// <summary>
        /// Handle all Input
        /// </summary>
        internal void HandleInput()
        {
            //MouseState mouseState = Mouse.GetState();
            // Calculate the mousePosition in the map
            //mMouseInWorldPosition = mCamera2D.ScreenToWorld(new Vector2(mouseState.X, mouseState.Y));
            mMouseInWorldPosition = Game1.mMapScreen.GetWorldPosition(InputManager.MousePosition().ToVector2());
            var range = ResolutionManager.Scale().X *20;

            // Some stuff only used for demonstration.
            // Spawn a battle Ship to the right of the flagship.
            if (InputManager.KeyDown(Keys.I))
            {
                mAiShipManager.SpawnAiBattleShip(FlagShip.Position + 200 * Vector2.UnitX);
            }
            // Spawn the Admiral fleet.
            if (InputManager.KeyDown(Keys.K))
            {
                Game1.mEventScreen.mEventManager.StartQuest3();
            }
            // Spawn the GhostShip.
            if (InputManager.KeyDown(Keys.N))
            {
                Game1.mMapScreen.mPlayerShipManager.mAiShipManager.SpawnGhostShip(new Vector2(4200, 860));
                Game1.mEventScreen.mEventManager.mGhostShipinGame = true;
            }
            // Add KartenFragment
            if (InputManager.KeyDown(Keys.L))
            {
                RessourceManager.AddRessource("mapParts", +1);
            }
            // Spawn own Battleship near us.
            if (InputManager.KeyDown(Keys.J))
            {
                SpawnBattleShip(FlagShip.Position - 200 * Vector2.UnitX, true);
            }

            if (InputManager.LeftMouseButtonDown())
            {
                //check if there are ships selected to sort out how the input should be processed.
                if (mSelectShipList.Count == 0)
                {
                    //check for every Ship, if it is selected
                    foreach (var ship in mAllShipList)
                    {
                        //testweise ein quadrat über die mitte des schiffs.
                        var selectRange = new CircleF(ship.Position, range);
                        if (!selectRange.Contains(mMouseInWorldPosition))
                        {
                            continue;
                        }
                        if (VisibilityManager.IsVisible(mMouseInWorldPosition))
                        {
                            ship.Selected = true;
                            mSelectShipList.Add(ship);
                        }

                        break; //when the mouse was clicked, obviously one ship can be selected.
                    }
                }
                else//unselect Ships
                {
                    UnselectShips();
                }
            }
            else if (InputManager.RightMouseButtonDown() && mSelectShipList.Count > 0)
            {
                if (InputManager.KeyPressed(InputManager.HotKey("Hk1")) || mShipState == ShipState.Attacking)
                {
                    SetShipsAttacking();
                }
                else if (InputManager.KeyPressed(InputManager.HotKey("Hk3")) || mShipState == ShipState.Defending)
                {
                    SetShipsDefending();
                }
                else if (InputManager.KeyPressed(InputManager.HotKey("Hk2")) || mShipState == ShipState.Boarding)
                {
                    SetShipsBoarding();
                }
                else
                {
                    SetShipsMoving();
                }
            }


            //Selectbox selecting
            if (InputManager.mSelectionBoxFinished)
            {
                InputManager.mSelectionBoxFinished = false;
                var selBoxOld  = InputManager.SelectBox();
                var shipsOwned = false;
                foreach (var ship in mAllShipList)
                {
                    if (!selBoxOld.Contains(ship.Position))
                    {
                        continue;
                    }
                    if (VisibilityManager.IsVisible(selBoxOld))
                    {
                        ship.Selected = true;
                        mSelectShipList.Add(ship);
                        if (ship.Owned)
                        {
                            shipsOwned = true;
                        }
                    }
                }
                if (shipsOwned)
                {
                    var actuallySelected = new List <AShip>();
                    foreach (var ship in SelectShipList)
                    {
                        if (ship.Owned)
                        {
                            actuallySelected.Add(ship);
                        }
                        else
                        {
                            ship.Selected = false;
                        }
                    }
                    SelectShipList = actuallySelected;
                }
            }

            //check for repairing commands
            if (InputManager.KeyPressed(InputManager.HotKey("Hk4")))
            {
                AddRepairingShips();
            }
            else if (InputManager.KeyReleased(InputManager.HotKey("Hk5"))) // Rum
            {
                foreach (var ship in mSelectShipList)
                {
                    if (RessourceManager.GetRessourceInt("rum") > 0)
                    {
                        Random random = new Random();
                        SoundManager.PlayEfx("efx/burping/" + random.Next(1, 7));
                        //increase crew if its the first rum
                        if (ship.RumBuffDuration <= 0f)
                        {
                            ship.AttackValue      += 5;
                            ship.EnterAttackValue += 5;
                            ship.RepairingValue   += 5;
                            ship.MovementSpeed    += 0.1f;
                        }
                        //increase duration and rumCounter
                        ship.RumDrunken++;
                        ship.RumBuffDuration += 5;
                        //ship.RumBuffDuration += 7;
                        RessourceManager.AddRessource("rum", -1);
                    }
                    else
                    {
                        SoundManager.PlayAmb("No_Rum", false);
                    }
                }
            }


            //Hud aufrufen

            /* if (mSelectShipList.Count >= 1)
             * {
             *   HudScreen.HudScreenInstance.ShowShipControl(mSelectShipList);
             * }
             * else
             * {
             *   HudScreen.HudScreenInstance.HideShipControl();
             * }*/
        }
Пример #54
0
 void Start()
 {
     inputManager = InputManager.GetInstance();
 }
Пример #55
0
 public void MoveCarets(int positions)
 {
     ConsoleManager.MoveCaret(positions);
     InputManager.MoveCaret(positions);
 }
 private void scrollMouseWheel(int dy)
 {
     AddStep($"scroll wheel {dy}", () => InputManager.ScrollVerticalBy(dy));
 }
Пример #57
0
        public void update(float elapsed)
        {
            if (StateManager.getInstance().CurrentGameState != GameState.Active)
            {
                if (InputManager.getInstance().wasKeyPressed(Keys.Enter))
                {
                    if (StateManager.getInstance().CurrentGameState == GameState.GameOver)
                    {
                        StateManager.getInstance().CurrentGameState = GameState.LoadGame;
                    }
                }
            }
            else if (StateManager.getInstance().CurrentGameState == GameState.Active)
            {
                this.playerOne.update(elapsed);
                if (!this.playerOne.BBox.Intersects(this.boundary) || this.playerOne.didICollideWithMyself())
                {
                    makeGameOver(playerTwo == null ? Winner.None : Winner.PlayerTwo);
                }
                List <Vector2> listeners = new List <Vector2> {
                    this.playerOne.Position
                };

                if (this.playerTwo != null)
                {
                    this.playerTwo.update(elapsed);
                    if (!this.playerTwo.BBox.Intersects(this.boundary) || this.playerTwo.didICollideWithMyself())
                    {
                        makeGameOver(Winner.PlayerOne);
                    }
                    else
                    {
                        bool p1CrashedIntoBody = this.playerTwo.wasCollisionWithBodies(playerOne.BBox);
                        bool p2CrashedIntoBody = this.playerOne.wasCollisionWithBodies(playerTwo.BBox);
                        // check if the players collided head on or crashed into each others bodies
                        if (this.playerTwo.BBox.Intersects(this.playerOne.BBox) || (p1CrashedIntoBody && p2CrashedIntoBody))
                        {
                            if (hud.PlayerOneScore > hud.PlayerTwoScore)
                            {
                                makeGameOver(Winner.PlayerOne);
                            }
                            else if (hud.PlayerTwoScore > hud.PlayerOneScore)
                            {
                                makeGameOver(Winner.PlayerTwo);
                            }
                            else
                            {
                                makeGameOver(Winner.None);
                            }
                        }
                        else if (p1CrashedIntoBody)
                        {
                            makeGameOver(Winner.PlayerTwo);
                        }
                        else if (p2CrashedIntoBody)
                        {
                            makeGameOver(Winner.PlayerOne);
                        }
                    }
                    listeners.Add(this.playerTwo.Position);
                }
                SoundManager.getInstance().update(listeners.ToArray());

                if (this.foodManager != null)
                {
                    this.foodManager.update(elapsed);
                    Food food = null;
                    for (int i = 0; i < this.foodManager.Nodes.Count; i++)
                    {
                        food = (Food)this.foodManager.Nodes[i];
                        if (food != null)
                        {
                            food.update(elapsed);
                            if (food.wasCollision(this.playerOne.BBox, this.playerOne.Heading))
                            {
                                this.playerOne.eat(food.SpeedMultiplier);
                                this.hud.PlayerOneScore += food.Points;
                            }
                            else if (this.playerTwo != null && food.wasCollision(this.playerTwo.BBox, this.playerTwo.Heading))
                            {
                                this.playerTwo.eat(food.SpeedMultiplier);
                                this.hud.PlayerTwoScore += food.Points;
                            }
                            if (food.Release)
                            {
                                this.foodManager.Nodes[i] = null;
                                this.foodManager.Nodes.RemoveAt(i);
                                i--;
                            }
                        }
                    }
                }

                if (this.portals != null)
                {
                    this.portals.update(elapsed);
                    if (this.portals.wasCollision(this.playerOne.BBox, this.playerOne.Position))
                    {
                        this.playerOne.handlePortalCollision(this.portals.WarpCoords);
                        this.hud.PlayerOneScore += this.portals.Points;
                    }
                    this.portals.wasCollision(this.playerOne.TailsBBox);
                    if (this.playerTwo != null)
                    {
                        if (this.portals.wasCollision(this.playerTwo.BBox, this.playerTwo.Position))
                        {
                            this.playerTwo.handlePortalCollision(this.portals.WarpCoords);
                            this.hud.PlayerTwoScore += this.portals.Points;
                        }
                        this.portals.wasCollision(this.playerTwo.TailsBBox);
                    }
                }

                if (this.walls != null)
                {
                    this.walls.update(elapsed);
                    if (this.walls.wasCollision(this.playerOne.BBox))
                    {
                        makeGameOver(playerTwo == null ? Winner.None : Winner.PlayerTwo);
                    }
                    else
                    {
                        if (this.playerTwo != null && this.walls.wasCollision(this.playerTwo.BBox))
                        {
                            makeGameOver(Winner.PlayerOne);
                        }
                    }
                }
            }

            if (this.hud != null)
            {
                this.hud.update(elapsed);
            }

            if (InputManager.getInstance().wasKeyPressed(Keys.Escape))
            {
                StateManager.getInstance().CurrentGameState = GameState.MainMenu;
            }
#if DEBUG
            if (InputManager.getInstance().wasKeyPressed(Keys.D1))
            {
                debugOn = !debugOn;
            }
            else if (InputManager.getInstance().wasKeyPressed(Keys.D2))
            {
                this.playerOne.eat(1f);
                if (this.playerTwo != null)
                {
                    this.playerTwo.eat(1f);
                }
            }
#endif
        }
Пример #58
0
    public void Update()
    {
        bool flag = !BasePV.IsMine;

        if (flag)
        {
            base.transform.position = Vector3.Lerp(base.transform.position, this.correctPlayerPos, Time.deltaTime * this.SmoothingDelay);
            base.transform.rotation = Quaternion.Lerp(base.transform.rotation, this.correctPlayerRot, Time.deltaTime * this.SmoothingDelay);
            this.barrel.rotation    = Quaternion.Lerp(this.barrel.rotation, this.correctBarrelRot, Time.deltaTime * this.SmoothingDelay);
        }
        else
        {
            Vector3 a      = new Vector3(0f, -30f, 0f);
            Vector3 vector = this.ballPoint.position;
            Vector3 a2     = this.ballPoint.forward * 300f;
            float   d      = 40f / a2.magnitude;
            this.myCannonLine.SetWidth(0.5f, 40f);
            this.myCannonLine.SetVertexCount(100);
            for (int i = 0; i < 100; i++)
            {
                this.myCannonLine.SetPosition(i, vector);
                vector += a2 * d + 0.5f * a * d * d;
                a2     += a * d;
            }
            float num   = 30f;
            bool  flag2 = InputManager.IsInputCannonHolding((int)InputCannon.CannonSlow);
            if (flag2)
            {
                num = 5f;
            }
            bool flag3 = this.isCannonGround;
            if (flag3)
            {
                bool flag4 = InputManager.IsInputCannonHolding((int)InputCannon.CannonUp);
                if (flag4)
                {
                    bool flag5 = this.currentRot <= 32f;
                    if (flag5)
                    {
                        this.currentRot += Time.deltaTime * num;
                        this.barrel.Rotate(new Vector3(0f, 0f, Time.deltaTime * num));
                    }
                }
                else
                {
                    bool flag6 = InputManager.IsInputCannonHolding((int)InputCannon.CannonDown) && this.currentRot >= -18f;
                    if (flag6)
                    {
                        this.currentRot += Time.deltaTime * -num;
                        this.barrel.Rotate(new Vector3(0f, 0f, Time.deltaTime * -num));
                    }
                }
                bool flag7 = InputManager.IsInputCannonHolding((int)InputCannon.CannonLeft);
                if (flag7)
                {
                    base.transform.Rotate(new Vector3(0f, Time.deltaTime * -num, 0f));
                }
                else
                {
                    bool flag8 = InputManager.IsInputCannonHolding((int)InputCannon.CannonRight);
                    if (flag8)
                    {
                        base.transform.Rotate(new Vector3(0f, Time.deltaTime * num, 0f));
                    }
                }
            }
            else
            {
                bool flag9 = InputManager.IsInputCannonHolding((int)InputCannon.CannonUp);
                if (flag9)
                {
                    bool flag10 = this.currentRot >= -50f;
                    if (flag10)
                    {
                        this.currentRot += Time.deltaTime * -num;
                        this.barrel.Rotate(new Vector3(Time.deltaTime * -num, 0f, 0f));
                    }
                }
                else
                {
                    bool flag11 = InputManager.IsInputCannonHolding((int)InputCannon.CannonDown) && this.currentRot <= 40f;
                    if (flag11)
                    {
                        this.currentRot += Time.deltaTime * num;
                        this.barrel.Rotate(new Vector3(Time.deltaTime * num, 0f, 0f));
                    }
                }
                bool flag12 = InputManager.IsInputCannonHolding((int)InputCannon.CannonLeft);
                if (flag12)
                {
                    base.transform.Rotate(new Vector3(0f, Time.deltaTime * -num, 0f));
                }
                else
                {
                    bool flag13 = InputManager.IsInputCannonHolding((int)InputCannon.CannonRight);
                    if (flag13)
                    {
                        base.transform.Rotate(new Vector3(0f, Time.deltaTime * num, 0f));
                    }
                }
            }
            bool flag14 = InputManager.IsInputCannonDown((int)InputCannon.CannonFire);
            if (flag14)
            {
                this.Fire();
            }
            else
            {
                bool flag15 = InputManager.IsInputCannonDown((int)InputCannon.CannonMount);
                if (flag15)
                {
                    bool flag16 = this.myHero != null;
                    if (flag16)
                    {
                        this.myHero.isCannon       = false;
                        this.myHero.myCannonRegion = null;
                        IN_GAME_MAIN_CAMERA.MainCamera.SetMainObject(this.myHero, true, false);
                        this.myHero.baseR.velocity = Vector3.zero;
                        this.myHero.BasePV.RPC("ReturnFromCannon", PhotonTargets.Others, new object[0]);
                        this.myHero.skillCDLast     = this.myHero.skillCDLastCannon;
                        this.myHero.skillCDDuration = this.myHero.skillCDLast;
                    }
                    PhotonNetwork.Destroy(base.gameObject);
                }
            }
        }
    }
Пример #59
0
 void Start()
 {
     message       = GameObject.Find("message").GetComponent <Text>();
     _inputManager = GameObject.Find("InputManager").GetComponent <InputManager>();
 }
Пример #60
0
 // Use this for initialization
 private void Awake()
 {
     s_inputManager = this;
 }