private void Awake()
    {
        /*if (Instance != null && Instance != this) {
         *              Destroy(gameObject);
         *      }
         *
         *      Instance = this;
         *
         *      // Delegates and event suscriptions
         *
         *      this.gameController = GameController.Instance;*/

        Instance = this;

        this.gameController = gameObjectController.GetComponent <GameController>();

        if (gameController)
        {
            gameController.tryAttemptsChangedEvent       += setTryAttemptsToggles;
            gameController.transformAttemptsChangedEvent += setTransformAttempsLabel;
        }
        Level currentLevel = LevelController.Instance.getCurrentLevel();

        maxSolveAttempts   = currentLevel.maxSolveAttempts;
        maxTransformations = currentLevel.maxTransformations;
        //setTryAttemptsToggles(LevelController.Instance.getCurrentLevel().maxSolveAttempts);
        //setTransformAttempsLabel(LevelController.Instance.getCurrentLevel().maxTransformations);
    }
示例#2
0
 public static GameInputController Instance()
 {
     if (instance == null)
     {
         instance = GameObject.FindObjectOfType <GameInputController>();
     }
     return(instance);
 }
示例#3
0
    void Awake()
    {
        m_cameraShift      = transform.position.y / Mathf.Tan(transform.eulerAngles.x * Mathf.Deg2Rad);
        transform.position = new Vector3(0.0f, transform.position.y, -m_cameraShift);
        onUpdatePosition();

        m_gameInputController = FindObjectOfType <GameInputController>();
    }
 private void Awake()
 {
     // Set up the reference to the aeroplane controller.
     m_Aeroplane = GetComponent <AeroplaneController>();
     if (GameInputController.Instance().GetDevice() != null)
     {
         m_Aeroplane.isJoystick = true;
     }
 }
    // Use this for initialization

    protected virtual void Start()
    {
        animator           = transform.GetComponent <PlayerAnimations> ().animator;
        lookAtCursor       = true;
        baseColliderRadius = transform.GetComponent <CapsuleCollider> ().radius;
        baseMoveSpeed      = moveSpeed;
        playerClass        = transform.GetComponent <Player> ();
        playerRigidbody    = transform.GetComponent <Rigidbody>();
        currentState       = PlayerStates.Idle;
        playerInput        = transform.GetComponent <GameInputController> ();
    }
示例#6
0
    private void Start()
    {
        // Delegates and event suscriptions

        GameInputController uiController = GameInputController.Instance;

        if (uiController)
        {
            uiController.positionChangedEvent += addTargetTranslate;
            uiController.rotationChangedEvent += setTargetRotation;
            uiController.scalenChangedEvent   += addTargetScale;

            uiController.resetGameEvent += initTargetTransforms;
        }
    }
    private void Awake()
    {
        DontDestroyOnLoad(this.gameObject);

        Cursor.lockState = CursorLockMode.Locked;

        game_state = GameState.MainMenu;
        game_state_change_event_args            = new GameStateChangeEventArgs();
        game_state_change_event_args.game_state = game_state;

        load_level_controller     = this.gameObject.AddComponent <GameLoadLevelController>();
        input_controller          = this.gameObject.GetComponent <GameInputController>();
        audio_controller          = this.gameObject.GetComponent <GameAudioController>();
        player_controller         = this.gameObject.GetComponent <GamePlayerController>();
        data_controller           = this.gameObject.GetComponent <GameDataController>();
        cutscene_controller       = this.gameObject.GetComponent <GameCutsceneController>();
        user_interface_controller = this.gameObject.GetComponent <GameUserInterfaceController>();
    }
示例#8
0
    private void Start()
    {
        if (mainCamera == null)
        {
            mainCamera = Camera.main;
        }

        transformTargetScroll = mainCamera.orthographicSize;

        startAngle = transform.rotation;
        setTargetRotation(startAngle);

        // Delegates and event suscriptions

        GameInputController uiController = GameInputController.Instance;

        if (uiController)
        {
            uiController.resetGameEvent += resetCameraPosition;
        }
    }
示例#9
0
    private void Start()
    {
        // Delegates and event suscriptions
        this.levelController  = LevelController.Instance;
        this.playerController = PlayerController.Instance;
        this.uiController     = GameInputController.Instance;

        this.uiController.resetGameEvent += resetTransformAttempts;

        if (xPlane)
        {
            xPlaneBehaviour = xPlane.GetComponent <PlaneBehaviour>();
        }

        if (zPlane)
        {
            zPlaneBehaviour = zPlane.GetComponent <PlaneBehaviour>();
        }

        setAndInitCurrentLevel();
    }
示例#10
0
        private void applySaveGame(SaveGame save)
        {
            Game.knowledge = save.Knowledge;

            // Models
            gameInput    = new GameInput();
            gameDialogue = new DialogueModel();

            levelModel                 = new LevelModel(LevelLoader.Load(save.LevelName, ll));
            characterModel             = new CharacterModel(levelModel.Avatar);
            characterModel.character.X = save.X;
            characterModel.character.Y = save.Y;

            // Controllers
            gameInputController = new GameInputController();
            gameInputController.SetModel(gameInput);

            characterController = new CharacterController();
            characterController.SetModel(characterModel);
            characterController.setInput(gameInput);
            characterController.SetLevel(levelModel);

            dialogueController = new DialogueController();
            dialogueController.setInput(gameInput);
            dialogueController.SetModel(gameDialogue);
            dialogueController.SetLevel(levelModel);

            levelController = new LevelController();
            levelController.SetModel(levelModel);
            levelController.SetInput(gameInput);
            levelController.SetDialogue(gameDialogue);

            buffers = new BooleanCanvas[]
            {
                new BooleanCanvas(GetWidth(), GetHeight()),
                new BooleanCanvas(GetWidth(), GetHeight())
            };

            bufferIndex = 0;
        }
        private void FixedUpdate()
        {
            // Read input for the pitch, yaw, roll and throttle of the aeroplane.


            float roll      = 0;
            float pitch     = 0;
            bool  airBrakes = false;
            float throttle  = -1;
            float yaw       = 0;

//			roll= CrossPlatformInputManager.GetAxis("Horizontal");
//			pitch= CrossPlatformInputManager.GetAxis("Vertical");
//			airBrakes = CrossPlatformInputManager.GetButton("Fire1");
//			roll=Input.GetAxis("joystick 1 analog 0");

            if (GameInputController.Instance().GetDevice() != null)
            {
                roll  = GameInputController.Instance().GetAxis("Analog0");
                pitch = -GameInputController.Instance().GetAxis("Analog1");
                yaw   = GameInputController.Instance().GetAxis("Analog2");
            }
            else
            {
                if (Input.GetKey(KeyCode.UpArrow))
                {
                    pitch = 1;
                }

                if (Input.GetKey(KeyCode.DownArrow))
                {
                    pitch = -1;
                }

                if (Input.GetKey(KeyCode.LeftArrow))
                {
                    roll = -1;
                }

                if (Input.GetKey(KeyCode.RightArrow))
                {
                    roll = 1;
                }

                if (Input.GetKey(KeyCode.Q))
                {
                    pow += Time.fixedDeltaTime;
                }

                if (Input.GetKey(KeyCode.W))
                {
                    pow -= Time.fixedDeltaTime;
                }
                pow = Mathf.Clamp(pow, -1, 1);
//				roll=CrossPlatformInputManager.GetAxis("Horizontal");
//				pitch= CrossPlatformInputManager.GetAxis("Vertical");
                PlayerController.Instance().powBar.fillAmount = (pow + 1) * 0.5f;
            }

            // auto throttle up, or down if braking.
//			Debug.Log(GameInputController.Instance().GetDevice());
            if (GameInputController.Instance().GetDevice() != null)
            {
                airBrakes = false;
                throttle  = -GameInputController.Instance().GetAxis("Analog3");

                PlayerController.Instance().powBar.fillAmount = (throttle + 1) * 0.5f;
            }
            else
            {
                airBrakes = Input.GetKey(KeyCode.LeftShift);
                throttle  = airBrakes ? -1 : pow;
            }


//			Debug.Log(throttle);
#if MOBILE_INPUT
            AdjustInputForMobileControls(ref roll, ref pitch, ref throttle);
#endif
            // Pass the input to the aeroplane
            if (GameInputController.Instance().GetDevice() != null)
            {
                m_Aeroplane.Move(roll, pitch, yaw, (throttle + 1) * 0.5f, airBrakes);
            }
            else
            {
                m_Aeroplane.Move(roll, pitch, yaw, throttle, airBrakes);
            }
        }
示例#12
0
 void Awake()
 {
     m_gameInputController = FindObjectOfType <GameInputController>();
 }
示例#13
0
 void Start()
 {
     input         = transform.GetComponent <GameInputController>();
     lastSpellCast = 0;
     spellCastSlot = -1;
 }
示例#14
0
    void Update()
    {
        if (GameInputController.Instance().GetButton(mainWeaponButton) || Input.GetKey(KeyCode.Z))
        {
            player.GetMainWeapon().FireButton();
        }

        if (GameInputController.Instance().GetButtonDown(mainWeaponButton) || Input.GetKeyDown(KeyCode.Z))
        {
            player.GetMainWeapon().FireButtonDown();
        }

        if (GameInputController.Instance().GetButtonUp(mainWeaponButton) || Input.GetKeyUp(KeyCode.Z))
        {
            player.GetMainWeapon().FireButtonUp();
        }



        if (GameInputController.Instance().GetButton(secondaryWeaponButton) || Input.GetKey(KeyCode.X))
        {
            player.GetSecondaryWeapon().FireButton();
        }

        if (GameInputController.Instance().GetButtonDown(secondaryWeaponButton) || Input.GetKeyDown(KeyCode.X))
        {
            player.GetSecondaryWeapon().FireButtonDown();
        }

        if (GameInputController.Instance().GetButtonUp(secondaryWeaponButton) || Input.GetKeyUp(KeyCode.X))
        {
            player.GetSecondaryWeapon().FireButtonUp();
        }



        if (GameInputController.Instance().GetButton(specialWeaponButton) || Input.GetKey(KeyCode.C))
        {
            player.GetSpecialWeapon().FireButton();
        }

        if (GameInputController.Instance().GetButtonDown(specialWeaponButton) || Input.GetKeyDown(KeyCode.C))
        {
            player.GetSpecialWeapon().FireButtonDown();
        }

        if (GameInputController.Instance().GetButtonUp(specialWeaponButton) || Input.GetKeyUp(KeyCode.C))
        {
            player.GetSpecialWeapon().FireButtonUp();
        }



        if ((GameInputController.Instance().GetButtonDown(mainSwitchButton) && !GameInputController.Instance().GetButton(mainWeaponButton)) || (Input.GetKeyDown(KeyCode.A) && !Input.GetKey(KeyCode.Z)))
        {
            player.SwitchMainWeapon();
            //Debug.Log(player.GetMainWeapon().name);
        }

        if ((GameInputController.Instance().GetButtonDown(secondarySwitchButton) && !GameInputController.Instance().GetButton(secondaryWeaponButton)) || (Input.GetKeyDown(KeyCode.S) && !Input.GetKey(KeyCode.X)))
        {
            player.SwitchSecondaryWeapon();
            //Debug.Log(player.GetSecondaryWeapon().name);
        }

        if ((GameInputController.Instance().GetButtonDown(specialSwitchButton) && !GameInputController.Instance().GetButton(specialWeaponButton)) || (Input.GetKeyDown(KeyCode.D) && !Input.GetKey(KeyCode.C)))
        {
            if (!player.GetSpecialWeapon().inSpecialState)
            {
                player.SwitchSpecialWeapon();
            }

            //Debug.Log(player.GetSpecialWeapon().name);
        }

        //txtWeapon.text=string.Format("W1: {0}\nW2: {1}\nSP: {2}",player.GetMainWeapon().weaponName,player.GetSecondaryWeapon().weaponName,player.GetSpecialWeapon().weaponName );

        mainWeaponText.text    = player.GetMainWeapon().weaponName;
        mainWeaponIcon.texture = player.GetMainWeapon().weaponIcon;

        secondaryWeaponText.text    = player.GetSecondaryWeapon().weaponName;
        secondaryWeaponIcon.texture = player.GetSecondaryWeapon().weaponIcon;

        specialWeaponText.text    = player.GetSpecialWeapon().weaponName;
        specialWeaponIcon.texture = player.GetSpecialWeapon().weaponIcon;

        Detect();
    }