Beispiel #1
0
    // Use this for initialization
    void Start()
    {
        trans       = GetComponent <Transform>();
        rb          = GetComponent <Rigidbody>();
        anim        = GetComponent <Animator>();
        playerStats = GetComponent <Player_Stats>();
        input       = GetComponent <GameInputs>();
        nearEnemies = GetComponent <HandleNearEnemies>();

        capsule       = GetComponent <CapsuleCollider>();
        capsuleHeight = capsule.height;
        capsuleCenter = capsule.center;

        rb.constraints          = RigidbodyConstraints.FreezeRotationX | RigidbodyConstraints.FreezeRotationY | RigidbodyConstraints.FreezeRotationZ;
        origGroundCheckDistance = groundCheckDistance;

        cam = Camera.main.transform;

        isGrounded = true;

        cursor = CursorLockMode.Locked;

        GameObject obj = GameObject.FindGameObjectWithTag("PlayerMelee");

        meleeCollider   = obj.GetComponent <BoxCollider>();
        meleeCollScript = obj.GetComponent <MeleeCollider>();

        isRunning = false;
    }
Beispiel #2
0
 new void Awake()
 {
     base.Awake();
     gameInpunts = new GameInputs();
     rb          = GetComponent <Rigidbody>();
     aud         = GetComponent <AudioSource>();
 }
Beispiel #3
0
 private void OnEnable()
 {
     if (_gameInputs == null)
     {
         _gameInputs = new GameInputs();
         _gameInputs.Gameplay.SetCallbacks(this);
         _gameInputs.Enable();
     }
 }
    private void Start()
    {
        _rigidbody = GetComponent <Rigidbody2D>();
        _inputs    = new GameInputs();
        _inputs.Enable();

        _inputs.Player.Move.performed += context => MovePlayer(context.ReadValue <Vector2>());
        _inputs.Player.Move.canceled  += context => MovePlayer(Vector2.zero);
    }
Beispiel #5
0
        private void OnEnable()
        {
            if (_gameInputs == null)
            {
                _gameInputs = new GameInputs();
                _gameInputs.Player.SetCallbacks(this);
            }

            _movementHandler = GetComponent <IMovementHandler>();
            _gameInputs.Enable();
        }
Beispiel #6
0
    public static void Initialize()
    {
        inputs = new Dictionary <GameInputs, KeyCode>();
        TextAsset jsonInputs = Resources.Load <TextAsset>(JsonPath.INPUT_PATH);
        Dictionary <string, string> dictionaryInputs = JsonConvert.DeserializeObject <Dictionary <string, string> >(jsonInputs.text);

        foreach (KeyValuePair <string, string> input in dictionaryInputs)
        {
            GameInputs gameInput = (GameInputs)Enum.Parse(typeof(GameInputs), input.Key);
            KeyCode    keyCode   = (KeyCode)Enum.Parse(typeof(KeyCode), input.Value);
            inputs.Add(gameInput, keyCode);
        }
    }
Beispiel #7
0
        public void Update(object sender, UpdateData data)
        {
            MultiState
                newState = new MultiState(),
                oldState = _inputState;

            List <GameInputs> gameInputs = Util.GetValues <GameInputs>();

            for (int i = 0; i < gameInputs.Count; ++i)
            {
                GameInputs
                    gameInput = gameInputs[i];

                if (!_inputMap.Keys.Contains(gameInput))
                {
                    continue;
                }

                MultiInput input = _inputMap[gameInput];

                bool
                    isDown  = newState.IsDown(input),
                    wasDown = oldState.IsDown(input);

                if (isDown && !wasDown)
                {
                    if (PressedEvent != null)
                    {
                        PressedEvent(this, new InputData(gameInput));
                    }
                }
                else if (!isDown && wasDown)
                {
                    if (ReleasedEvent != null)
                    {
                        ReleasedEvent(this, new InputData(gameInput));
                    }
                }

                if (isDown)
                {
                    if (HeldEvent != null)
                    {
                        HeldEvent(this, new InputData(gameInput));
                    }
                }
            }

            _inputState = newState;
        }
Beispiel #8
0
    // Use this for initialization
    void Start()
    {
        health     = maxHealth;
        stamina    = maxStamina;
        invCounter = maxInv;

        playerCont = GetComponent <PlayerController>();
        input      = GetComponent <GameInputs>();
        partCont   = GameObject.FindGameObjectWithTag("ParticleController").GetComponent <ParticleController>();

        potionNumberUI = GameObject.FindGameObjectWithTag("Potion_UI").GetComponent <Text>();
        coinUI         = GameObject.FindGameObjectWithTag("Coin_UI").GetComponent <Text>();

        loseUI = GameObject.FindGameObjectWithTag("Lose_UI");
        loseUI.SetActive(false);
    }
Beispiel #9
0
    void Start()
    {
        angles = transform.eulerAngles;
        x      = angles.y;
        y      = angles.x;

        isTargeting = false;

        playerTarget = GameObject.FindGameObjectWithTag("Player").GetComponent <Transform>();
        //enemyTarget = GameObject.FindGameObjectWithTag("Enemy").GetComponent<Transform>();

        input       = GameObject.FindGameObjectWithTag("Player").GetComponent <GameInputs>();
        nearEnemies = GameObject.FindGameObjectWithTag("Player").GetComponent <HandleNearEnemies>();
        player      = GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerController>();

        distance = desiredDist;
    }
Beispiel #10
0
        /// <summary>
        ///     Defines the entry point of the application.
        /// </summary>
        /// <param name="args">The arguments.</param>
        public static void Main(string[] args)
        {
            //TestBoardExtensions();
            GameInputs  input         = GameProcessor.GetEnumFromArg(args, 0, GameInputs.Unset);
            OptimizerId optimizer     = GameProcessor.GetEnumFromArg(args, 1, OptimizerId.Schaepi);
            Stopwatch   totalDuration = new Stopwatch();

            totalDuration.Start();
            if (input == GameInputs.Unset)
            {
                GameProcessor.ComputeAll <IGameOptimizer <Game, CacheUsages>, Game, CacheUsages, GameInputs>(optimizer, EnumExtensions.GetValues <GameInputs>().ExceptElts(GameInputs.Unset).ToArray());
            }
            else
            {
                GameProcessor.Compute <IGameOptimizer <Game, CacheUsages>, Game, CacheUsages, GameInputs>(optimizer, input);
            }
            totalDuration.DisplayTime("Finished !");
            Console.ReadLine();
            Console.WriteLine("Tap to quit");
            Console.ReadLine();
        }
Beispiel #11
0
        /// <summary>
        ///     Defines the entry point of the application.
        /// </summary>
        /// <param name="args">The arguments.</param>
        public static void Main(string[] args)
        {
            //TestBoardExtensions();
            GameInputs  input     = GameProcessor.GetEnumFromArg(args, 0, GameInputs.Unset);
            OptimizerId optimizer = GameProcessor.GetEnumFromArg(args, 1, OptimizerId.Schepi);
            //OptimizerId optimizer = GameProcessor.GetEnumFromArg(args, 1, OptimizerId.Jon);
            Stopwatch totalDuration = new Stopwatch();

            totalDuration.Start();
            if (input == GameInputs.Unset)
            {
                GameProcessor.ComputeAll <IGameOptimizer <Game, PizzaSlices>, Game, PizzaSlices, GameInputs>(optimizer);
            }
            else
            {
                GameProcessor.Compute <IGameOptimizer <Game, PizzaSlices>, Game, PizzaSlices, GameInputs>(input, optimizer);
            }
            totalDuration.DisplayTime("Finished !");
            Console.ReadLine();
            Console.WriteLine("Tap to quit");
            Console.ReadLine();
        }
Beispiel #12
0
    // Start is called before the first frame update
    protected override void Awake()
    {
        base.Awake();
        keys    = new List <string>();
        _inputs = new GameInputs();
        _inputs.Gameplay.Rewind.started  += ctx => rewinding = StartCoroutine(nameof(repeatedlyRewind));
        _inputs.Gameplay.Rewind.canceled += ctx =>
        {
            HideRewindScreen();
            StopCoroutine(rewinding);
        };
        _inputs.Gameplay.North.started  += ctx => moveDirection += Vector2Int.up;
        _inputs.Gameplay.North.canceled += ctx => moveDirection -= Vector2Int.up;
        _inputs.Gameplay.East.started   += ctx => moveDirection += Vector2Int.right;
        _inputs.Gameplay.East.canceled  += ctx => moveDirection -= Vector2Int.right;
        _inputs.Gameplay.South.started  += ctx => moveDirection += Vector2Int.down;
        _inputs.Gameplay.South.canceled += ctx => moveDirection -= Vector2Int.down;
        _inputs.Gameplay.West.started   += ctx => moveDirection += Vector2Int.left;
        _inputs.Gameplay.West.canceled  += ctx => moveDirection -= Vector2Int.left;

        _inputs.Gameplay.Escape.performed += ctx => Escape.StartEscaping();
    }
Beispiel #13
0
 public InputData(GameInputs input)
 {
     _input = input;
 }
Beispiel #14
0
 void Awake()
 {
     gameInputs = new GameInputs();
     anim       = GetComponent <Animator>();
     rb         = GetComponent <Rigidbody>();
 }
Beispiel #15
0
 public static bool GetKey(GameInputs gameInput)
 {
     return(Input.GetKey(inputs[gameInput]));
 }
Beispiel #16
0
 public GameActions(GameInputs wrapper)
 {
     m_Wrapper = wrapper;
 }
Beispiel #17
0
 public InputData(GameInputs input)
 {
     _input = input;
 }
Beispiel #18
0
 void Awake()
 {
     rb         = GetComponent <Rigidbody>();
     gameInputs = new GameInputs();
 }
 // Use this for initialization
 void Start()
 {
     player = GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerController>();
     input  = GameObject.FindGameObjectWithTag("Player").GetComponent <GameInputs>();
 }
Beispiel #20
0
 public PlayerInputValues()
 {
     inputActions = new GameInputs();
 }
Beispiel #21
0
 // Start is called before the first frame update
 void Start()
 {
     _renderer         = GetComponent <SpriteRenderer>();
     _renderer.enabled = false;
     _inputs           = new GameInputs();
 }