private void Awake()
    {
        // set the static variable so that other classes can easily use this class
        instance = this;

        character = GetComponent <Character2D>();
    }
Exemplo n.º 2
0
 void TryToFindPlayer()
 {
     // Obtem a instancia do objeto do jogador
     playerRefence = FindObjectOfType <Character2DController> ();
     if (playerRefence != null)
     {
         // Set current position camera to player
         UpdateCameraPosition();
     }
 }
Exemplo n.º 3
0
 void OnTriggerEnter(Collider other)
 {
     foreach (string currentTag in tagsCanCollide)
     {
         if (other.tag.Equals(currentTag))
         {
             objectToShow.SetActive(true);
             Character2DController jogador = (Character2DController)FindObjectOfType(typeof(Character2DController));
             jogador.SetStateAnimation(EnumPlayerState.STAY);
             return;
         }
     }
 }
Exemplo n.º 4
0
    public void switchCharacters(float delaySeconds)
    {
        //Note: changge to loop if we have more than 2 chars.

        bool success = players[(int)PlayerNumber.One - 1].switchToPlayer(PlayerNumber.Two,
                                                                         players[(int)PlayerNumber.Two - 1],
                                                                         delaySeconds);

        if (success)
        {
            Character2DController tmp = players[(int)PlayerNumber.One - 1];
            players[(int)PlayerNumber.One - 1] = players[(int)PlayerNumber.Two - 1];
            players[(int)PlayerNumber.Two - 1] = tmp;

            EventManager.PlayerSwitch();
        }
    }
    //params PlayerNumber number, Character2DController other, float delaySeconds
    private IEnumerator delaySwitch(PlayerNumber number, Character2DController other, float delaySeconds)
    {
        /*
         * Debug.Log("SWITCH in progress; number: "+number+"; != playerNumber: "+
         *        playerNumber+"; delaySeconds: "+delaySeconds+
         *        ";");
         */
        yield return(new WaitForSeconds(delaySeconds));

        //swap mesh
        Transform charMeshParent = characterMesh.transform.parent;

        other.setNewCharacterMesh(characterMesh, other.characterMesh.transform.parent);
        setNewCharacterMesh(other.characterMesh, charMeshParent);

        //swap IDs
        other.playerNumber = this.playerNumber;
        playerNumber       = number;
    }
    public bool switchToPlayer(PlayerNumber number, Character2DController other, float delaySeconds)
    {
        if (number != playerNumber && !(switchInProgress || other.switchInProgress) && !isPaused)
        {
            switchInProgress_ = true;

            //handle necessary swaps

            //TODO: start to play swap animation

            //swap the chars in the middle of the animation.

            StartCoroutine(delaySwitch(number, other, delaySeconds));


            //note: this doesn't actually check if the swap was successful, but if the references are there it will certainly work.
            return(true);
        }
        else
        {
            return(false);
        }
    }
Exemplo n.º 7
0
 private void Start()
 {
     playerBase          = GetComponent <PlayerBase>();
     rb                  = GetComponent <Rigidbody2D>();
     characterController = GetComponent <Character2DController>();
 }
Exemplo n.º 8
0
 // Start is called before the first frame update
 private void Start()
 {
     rb   = GetComponent <Rigidbody2D>();
     move = GetComponent <Character2DController>();
 }
 void Start()
 {
     player         = FindObjectOfType <Character2DController>();
     timeMinToShoot = Random.Range(timeMinToShoot, timeMaxToShoot);
 }
Exemplo n.º 10
0
 private void OnEnable()
 {
     _player           = GameObject.FindGameObjectWithTag("Player").transform;
     _playerController = _player.GetComponent <Character2DController>();
 }
 // Start is called before the first frame update
 void Start()
 {
     controller2D = GetComponent <Character2DController>();
     anim         = GetComponent <Animator>();
 }