Example #1
0
 public void OnDestroy()
 {
     _toolTipCalcs.OnDisable();
     _inputScheme  = null;
     _myDataHub    = null;
     _toolTipCalcs = null;
 }
Example #2
0
 /// <summary>
 /// Deactivate if not already deactivated
 /// </summary>
 /// <param name="nextScheme">
 /// The next scheme that will be activated.
 /// Will be null on start up.
 /// </param>
 public virtual void Deactivate(InputScheme nextScheme)
 {
     if (enabled)
     {
         enabled = false;
     }
 }
Example #3
0
 /// <summary>
 /// Activate if not already activated
 /// </summary>
 /// <param name="previousScheme">
 /// The scheme that was previously enabled.
 /// Will be null on start up.
 /// </param>
 public virtual void Activate(InputScheme previousScheme)
 {
     if (!enabled)
     {
         enabled = true;
     }
 }
Example #4
0
		/// <summary>
		/// Initialize the team
		/// </summary>
		public override void LoadContent()
		{

			Batch = new SpriteBatch();

			System.Diagnostics.Stopwatch watch = new System.Diagnostics.Stopwatch();
			watch.Start();

			// Keyboard input scheme
			InputScheme = ResourceManager.CreateAsset<InputScheme>(Game.InputSchemeName);
			if (InputScheme == null)
			{
				Trace.WriteLine("ERROR !!! No InputSchema detected !!!");
				InputScheme = new InputScheme();
				InputScheme["MoveForward"] = Keys.Z;
				InputScheme["MoveBackward"] = Keys.S;
				InputScheme["StrafeLeft"] = Keys.Q;
				InputScheme["StrafeRight"] = Keys.D;
				InputScheme["TurnLeft"] = Keys.A;
				InputScheme["TurnRight"] = Keys.E;
				InputScheme["Inventory"] = Keys.I;
				InputScheme["SelectHero1"] = Keys.D1;
				InputScheme["SelectHero2"] = Keys.D2;
				InputScheme["SelectHero3"] = Keys.D3;
				InputScheme["SelectHero4"] = Keys.D4;
				InputScheme["SelectHero5"] = Keys.D5;
				InputScheme["SelectHero6"] = Keys.D6;
			}
			Trace.WriteLine("InputScheme ({0} ms)", watch.ElapsedMilliseconds);


			// Interface tileset
			TileSet = ResourceManager.CreateSharedAsset<TileSet>("Interface", "Interface");

			// Heroe's heads
			Heads = ResourceManager.CreateAsset<TileSet>("Heads");


			// Fonts
			InventoryFont = ResourceManager.CreateSharedAsset<BitmapFont>("inventory", "inventory");
			OutlinedFont = ResourceManager.CreateSharedAsset<BitmapFont>("outline", "outline");

			// Misc init
			SpellBook.LoadContent();
			GameMessage.Init();

			Hands = new Item[]
			{
				ResourceManager.CreateAsset<Item>("left hand"),
				ResourceManager.CreateAsset<Item>("right hand")
			};



			watch.Stop();
			Trace.WriteLine("[GameScreen] LoadContent() - finished ! ({0} ms)", watch.ElapsedMilliseconds);
		}
Example #5
0
		/// <summary>
		/// Default constructor
		/// </summary>
		/// <param name="node">Dungeon node definition</param>
		public DungeonForm(XmlNode node)
		{
			InitializeComponent();

			// Create the dungeon
			Dungeon dungeon = new Dungeon();
			dungeon.Load(node);
			dungeon.Init();


			ItemTileSetBox.DataSource = ResourceManager.GetAssets<TileSet>();
			ItemTileSetBox.SelectedItem = dungeon.ItemTileSetName;

			DecorationNameBox.Items.AddRange(ResourceManager.GetAssets<DecorationSet>().ToArray());
			DecorationNameBox.Items.Insert(0, "");
			WallTileSetNameBox.Items.AddRange(ResourceManager.GetAssets<TileSet>().ToArray());
			WallTileSetNameBox.Items.Insert(0, "");





			PreviewLoc = new DungeonLocation(dungeon.StartLocation);


			//		RebuildMazeList();
			DungeonNoteBox.Text = dungeon.Note;

			StartLocationBox.Dungeon = dungeon;
			StartLocationBox.SetTarget(dungeon.StartLocation);


			KeyboardScheme = ResourceManager.CreateAsset<InputScheme>(Game.InputSchemeName);
			if (KeyboardScheme == null)
			{
				KeyboardScheme = new InputScheme();
				KeyboardScheme["MoveForward"] = Keys.Z;
				KeyboardScheme["MoveBackward"] = Keys.S;
				KeyboardScheme["StrafeLeft"] = Keys.Q;
				KeyboardScheme["StrafeRight"] = Keys.D;
				KeyboardScheme["TurnLeft"] = Keys.A;
				KeyboardScheme["TurnRight"] = Keys.E;
				KeyboardScheme["Inventory"] = Keys.I;
				KeyboardScheme["SelectHero1"] = Keys.D1;
				KeyboardScheme["SelectHero2"] = Keys.D2;
				KeyboardScheme["SelectHero3"] = Keys.D3;
				KeyboardScheme["SelectHero4"] = Keys.D4;
				KeyboardScheme["SelectHero5"] = Keys.D5;
				KeyboardScheme["SelectHero6"] = Keys.D6;
			}




			Dungeon = dungeon;
		}
 public PlayerInputHandlerDefaultState(System.Object objectAttachedTo, GameObject gameobjectAttachedTo, InputHandlerUpdater inputHandlerUpdaterAttachedTo)
 {
     this.objectAttachedTo     = objectAttachedTo;
     this.gameobjectAttachedTo = gameobjectAttachedTo;
     this.InputHandlerUpdater  = inputHandlerUpdaterAttachedTo;
     moveCommand   = new SetRigidbodyVelocityCommand(this);
     rotateCommand = new RotateRigidbodyCommand(this);
     inputScheme   = gameobjectAttachedTo.GetComponent <IInputSchemeHolder>().GetInputScheme();
     //stringBlock.ControllerOrder = 1.ToString();
 }
Example #7
0
        /// <summary>
        /// Default constructor
        /// </summary>
        /// <param name="node">Dungeon node definition</param>
        public DungeonForm(XmlNode node)
        {
            InitializeComponent();

            // Create the dungeon
            Dungeon dungeon = new Dungeon();

            dungeon.Load(node);
            dungeon.Init();


            ItemTileSetBox.DataSource   = ResourceManager.GetAssets <TileSet>();
            ItemTileSetBox.SelectedItem = dungeon.ItemTileSetName;

            DecorationNameBox.Items.AddRange(ResourceManager.GetAssets <DecorationSet>().ToArray());
            DecorationNameBox.Items.Insert(0, "");
            WallTileSetNameBox.Items.AddRange(ResourceManager.GetAssets <TileSet>().ToArray());
            WallTileSetNameBox.Items.Insert(0, "");



            PreviewLoc = new DungeonLocation(dungeon.StartLocation);


            //		RebuildMazeList();
            DungeonNoteBox.Text = dungeon.Note;

            StartLocationBox.Dungeon = dungeon;
            StartLocationBox.SetTarget(dungeon.StartLocation);


            KeyboardScheme = ResourceManager.CreateAsset <InputScheme>(Game.InputSchemeName);
            if (KeyboardScheme == null)
            {
                KeyboardScheme = new InputScheme();
                KeyboardScheme["MoveForward"]  = Keys.Z;
                KeyboardScheme["MoveBackward"] = Keys.S;
                KeyboardScheme["StrafeLeft"]   = Keys.Q;
                KeyboardScheme["StrafeRight"]  = Keys.D;
                KeyboardScheme["TurnLeft"]     = Keys.A;
                KeyboardScheme["TurnRight"]    = Keys.E;
                KeyboardScheme["Inventory"]    = Keys.I;
                KeyboardScheme["SelectHero1"]  = Keys.D1;
                KeyboardScheme["SelectHero2"]  = Keys.D2;
                KeyboardScheme["SelectHero3"]  = Keys.D3;
                KeyboardScheme["SelectHero4"]  = Keys.D4;
                KeyboardScheme["SelectHero5"]  = Keys.D5;
                KeyboardScheme["SelectHero6"]  = Keys.D6;
            }



            Dungeon = dungeon;
        }
Example #8
0
 public void CopyFrom(InputScheme other)
 {
     this.UseJoysticks      = other.UseJoysticks;
     this.PositiveXKey      = other.PositiveXKey;
     this.NegativeXKey      = other.NegativeXKey;
     this.PositiveYKey      = other.PositiveYKey;
     this.NegativeYKey      = other.NegativeYKey;
     this.PositiveShootXKey = other.PositiveShootXKey;
     this.NegativeShootXKey = other.NegativeShootXKey;
     this.PositiveShootYKey = other.PositiveShootYKey;
     this.NegativeShootYKey = other.NegativeShootYKey;
     this.ReverseTimeKey    = other.ReverseTimeKey;
     this.PauseKey          = other.PauseKey;
 }
    // Start is called before the first frame update
    void Start()
    {
        data    = GetComponent <TankData>();
        motor   = GetComponent <TankMotor>();
        shooter = GetComponent <TankShooter>();

        if (this.gameObject == GameManager.Instance.Players[0])
        {
            inputScheme = InputScheme.WASD;
        }
        else
        {
            inputScheme = InputScheme.arrowKeys;
        }
    }
Example #10
0
    public InputScheme inputScheme = InputScheme.arrowKeys; // Default control scheme is set to arrow keys, but can be changed

    // Start is called before the first frame update
    void Start()
    {
        data    = GetComponent <TankData>();
        motor   = GetComponent <TankMotor>();
        shooter = GetComponent <TankShooter>();

        lastEventTime = Time.time - timerDelay;

        if (this.gameObject == GameManager.Instance.Players[0])
        {
            inputScheme = InputScheme.arrowKeys;
        }
        if (this.gameObject == GameManager.Instance.Players[1])
        {
            inputScheme = InputScheme.WASD;
        }
    }
Example #11
0
 /// <summary>
 /// Checks the different schemes and activates them if needed
 /// </summary>
 protected virtual void Update()
 {
     foreach (InputScheme scheme in m_InputSchemes)
     {
         if (scheme.enabled || !scheme.shouldActivate)
         {
             continue;
         }
         if (m_CurrentScheme != null)
         {
             m_CurrentScheme.Deactivate(scheme);
         }
         scheme.Activate(m_CurrentScheme);
         m_CurrentScheme = scheme;
         break;
     }
 }
        /// <summary>
        /// Constructor
        /// </summary>
        public InputSchemeForm(XmlNode node)
        {
            InitializeComponent();



            Scheme = new InputScheme();
            Scheme.Load(node);

            KeyBox.BeginUpdate();
            foreach (string s in Enum.GetNames(typeof(Keys)))
            {
                KeyBox.Items.Add(s);
            }
            KeyBox.EndUpdate();


            BuildList();
        }
Example #13
0
 /// <summary>
 /// Cache the schemes and activate the default
 /// </summary>
 protected virtual void Awake()
 {
     m_InputSchemes = GetComponents <InputScheme>();
     foreach (InputScheme scheme in m_InputSchemes)
     {
         scheme.Deactivate(null);
         if (m_CurrentScheme == null && scheme.isDefault)
         {
             m_DefaultScheme = scheme;
         }
     }
     if (m_DefaultScheme == null)
     {
         Debug.LogError("[InputSchemeSwitcher] Default scheme not set.");
         return;
     }
     m_DefaultScheme.Activate(null);
     m_CurrentScheme = m_DefaultScheme;
 }
Example #14
0
        public Tank(float acceleration0, float aimAcceleration0, float turnFactor0, Vector2 position0, Vector2 direction, Color color, InputScheme input0, PhysicsLayer layer)
        {
            List <Mesh> Meshes = new List <Mesh>();

            //Hull
            Meshes.Add(new Mesh(new Vector2[4] {
                new Vector2(-2, 1), new Vector2(2, 1), new Vector2(2, -1), new Vector2(-2, -1)
            }, this, color, PrimitiveType.LineLoop));

            //Forward Indicator
            Meshes.Add(new Mesh(new Vector2[2] {
                new Vector2(1.75f, 1), new Vector2(1.75f, -1)
            }, this, color, PrimitiveType.Lines));

            //Tower
            Meshes.Add(new Mesh(new Vector2[4] {
                new Vector2(-.75f, .75f), new Vector2(.75f, .75f), new Vector2(.75f, -.75f), new Vector2(-.75f, -.75f)
            }, this, color, PrimitiveType.LineLoop));

            //Cannon
            Meshes.Add(new Mesh(new Vector2[4] {
                new Vector2(.75f, .15f), new Vector2(3, .15f), new Vector2(3, -.15f), new Vector2(.75f, -.15f)
            }, this, color, PrimitiveType.LineLoop));

            meshes   = Meshes;
            forward  = direction;
            position = position0;
            prevPos  = position;

            acceleration    = acceleration0;
            aimAcceleration = aimAcceleration0;
            turnFactor      = turnFactor0;
            input           = input0;

            for (int i = 0; i < meshes.Count; ++i)
            {
                meshes[i].forward = direction;
            }

            collider = new Collider(this, meshes[0], layer);

            Initialize();
        }
Example #15
0
 void Update()
 {
     for (int i = availableInputSchemes.items.Count - 1; i >= 0; i--)
     {
         if (playerRoster.FreeSlots() == 0)
         {
             PauseMonitor();
             break;
         }
         InputScheme inputScheme = availableInputSchemes.items[i];
         if (inputScheme.GetInputDirection() != Vector2.zero)
         {
             availableInputSchemes.UnregisterItem(inputScheme);
             takenInputSchemes.RegisterItem(inputScheme);
             PlayerInfo playerInfo = Instantiate(defaultPlayerInfo);
             playerInfo.inputScheme.Value = inputScheme;
             playerRoster.RegisterItem(playerInfo);
             OnDetectNewPlayer.Invoke(playerInfo);
         }
     }
 }
Example #16
0
    //put in other class
    public void GeneratePlayers()
    {
        foreach (ControllerInformation c in connectedControllers)
        {
            GameObject  playerCharacter = Instantiate(Resources.Load("InsertCharacterStringHere") as GameObject);
            InputScheme inputScheme     = new InputScheme();

            //Assign inputScheme
            if (c.controller == ControllerInformation.ControllerType.Keyboard)
            {
                //if there is already a custom profile created, load that.
                if (Resources.Load("CustomKeyboardInput"))
                {
                    inputScheme = Resources.Load("CustomKeyboardInput") as InputScheme;
                }
                else
                {
                    //load the default profile for keyboard
                    inputScheme = Resources.Load("DefaultKeyboardInput") as InputScheme;
                }
            }

            else if (c.controller == ControllerInformation.ControllerType.Controller)
            {
                //if there is already a custom profile created, load that.
                if (Resources.Load(c.controllerOrder + "CustomControllerInput"))
                {
                    inputScheme = Resources.Load(c.controllerOrder + "CustomControllerInput") as InputScheme;
                }
                else
                {
                    //load the default profile for controller
                    inputScheme = Resources.Load("DefaultControllerInput") as InputScheme;
                    inputScheme.ControllerOrder = c.controllerOrder;
                }
            }
            playerCharacter.GetComponent <IInputSchemeHolder>().SetInputScheme(inputScheme);
        }
    }
Example #17
0
 public void MakeInputArrows()
 {
     inputScheme = InputScheme.arrowKeys;
 }
Example #18
0
 public void MakeInputWASD()
 {
     inputScheme = InputScheme.WASD;
 }
Example #19
0
 public void UseEZServiceLocator() => _inputScheme = EZService.Locator.Get <InputScheme>(this);
Example #20
0
 private bool HasScheme(InputScheme scheme) => scheme != null;
Example #21
0
 public void SetInputScheme(InputScheme inputScheme)
 {
     this.inputScheme = inputScheme;
 }
Example #22
0
 public void UseEZServiceLocator()
 {
     _inputScheme    = EZService.Locator.Get <InputScheme>(this);
     _uiHistoryTrack = EZService.Locator.Get <IHistoryTrack>(this);
     _myDataHub      = EZService.Locator.Get <IDataHub>(this);
 }
		public virtual void SetInputScheme(InputScheme inputScheme)
		{
			_inputScheme = inputScheme;
		}
Example #24
0
 public void UseEZServiceLocator()
 {
     Scheme           = EZService.Locator.Get <InputScheme>(this);
     _canvasOrderData = EZService.Locator.Get <ICanvasOrderData>(this);
 }
Example #25
0
 private void OnInputChange(InputScheme oldVal, InputScheme newVal)
 {
     UpdateLabels();
 }
Example #26
0
 public void UseEZServiceLocator()
 {
     _inputScheme = EZService.Locator.Get <InputScheme>(this);
     _myDatHub    = EZService.Locator.Get <IDataHub>(this);
 }
Example #27
0
 public virtual void SetInputScheme(InputScheme inputScheme)
 {
     _inputScheme = inputScheme;
 }