Ejemplo n.º 1
0
    void Awake()
    {
        if (Instance != null && Instance != this)
        {
            Destroy(gameObject);
        }
        else
        {
            Instance = this;
        }

        DontDestroyOnLoad(gameObject);


        if (OnSelectedTarget == null)
        {
            OnSelectedTarget = new ActionUnitEvent();
        }
        OnSelectedTarget.AddListener(SelectTargetForMonster);
    }
Ejemplo n.º 2
0
    private AudioSource[] sounds; // multiple audios

    void Awake()
    {
        // instantiate reference to components: rigidbody, animator, and player health
        rb     = GetComponent <Rigidbody> ();
        health = GetComponent <PlayerHealth>();
        anim   = GetComponent <Animator> ();

        // [0] is Jump, [1] is walking, [2] is shooting, [3] is dying
        // Note that the field "sounds" is an array.
        sounds = GetComponents <AudioSource>();

        // Game starts as unpaused
        isPaused = false;

        // Sets player control depending on which player this is
        whoUAre = gameObject.name;
        if (whoUAre == "Player1")
        {
            whichPlayerAreU = "P1_";
        }
        else if (whoUAre == "Player2")
        {
            whichPlayerAreU = "P2_";
        }

        whichSystemAreUOn = SystemInfo.operatingSystemFamily.ToString() + "_";          // returns MacOSX_ if game is running on Mac or Windows_ if Windows

        // Assigns controls based on which player you are and which system you are playing on (because controller mapping is different across platforms)
        P_RightTrigger    = whichSystemAreUOn + whichPlayerAreU + "Right Trigger"; // eg "MacOSX_P1_Right Trigger"
        P_Start           = whichSystemAreUOn + whichPlayerAreU + "Start";         // eg "Windows_P2_Start"
        P_LeftHorizontal  = whichSystemAreUOn + whichPlayerAreU + "Left Horizontal";
        P_LeftVertical    = whichSystemAreUOn + whichPlayerAreU + "Left Vertical";
        P_RightHorizontal = whichSystemAreUOn + whichPlayerAreU + "Right Horizontal";
        P_RightVertical   = whichSystemAreUOn + whichPlayerAreU + "Right Vertical";
        P_LeftBumper      = whichSystemAreUOn + whichPlayerAreU + "Left Bumper";
        P_Jump            = whichSystemAreUOn + whichPlayerAreU + "Jump";

        // Instantiate reference to pause menu control
        inGameMenuControl = pauseMenu.GetComponent <InGameMenuControl> ();
    }