Ejemplo n.º 1
0
    /// <summary>
    /// Grabs an object
    /// </summary>
    /// <param name="_objectID">ID of the object to grab</param>
    public virtual void GrabObject(int _objectID)
    {
        // If the character already have a projectile, return
        if (projectile)
        {
            return;
        }

        // Find the object via photon ID & get its Throwable component
        PhotonView _objectPhoton = PhotonView.Find(_objectID);

        if (_objectPhoton)
        {
            TDS_Throwable _projectile = _objectPhoton.GetComponent <TDS_Throwable>();

            if (!_projectile)
            {
                TDS_CustomDebug.CustomDebugLogWarning($"The object \"{_objectPhoton.name}\" couldn't be found");
                return;
            }

            // If the character can grab the object, stock it
            if (_projectile.Grab(this))
            {
                projectile = _projectile;
            }
        }
        else
        {
            TDS_CustomDebug.CustomDebugLogWarning($"The object with PhotonID \"{_objectID}\" doesn't have the \"TDS_Throwable\" component !");
            return;
        }
    }
Ejemplo n.º 2
0
    /// <summary>
    /// Makes the player jump plus or less high depending on the time the key is pressed
    /// </summary>
    /// <param name="_key">Jump's key</param>
    /// <returns></returns>
    private IEnumerator JumpCoroutine(KeyCode _key)
    {
        TDS_CustomDebug.CustomDebugLog("Start Jump !");

        // Timer used for the maximum jump time length
        float _timer = 0;

        // Adds the initial jump force to the rigidbody
        rigidbody.AddForce(Vector3.up * JumpForce);

        // While the jump key is hold and the jump is not at its maximum time length, go higher
        while (Input.GetKey(_key) && (_timer < JumpMaxTime))
        {
            // Increases the rigidbody velocity
            rigidbody.AddForce(Vector3.up * JumpForceIncrease);

            // Wait for the next frame
            yield return(new WaitForEndOfFrame());

            // Increases the timer
            _timer += Time.deltaTime;
        }

        TDS_CustomDebug.CustomDebugLog("End Jump...");
    }
Ejemplo n.º 3
0
 private void Awake()
 {
     // Set the instance if needed
     if (!Instance)
     {
         Instance = this;
     }
     else
     {
         TDS_CustomDebug.CustomDebugLog("There is already a camera instance in this scene ! Destroys CameraBehaviour script", "Lucas");
         Destroy(this);
         return;
     }
 }
Ejemplo n.º 4
0
    private void Awake()
    {
        if (!Instance)
        {
            Instance = this;
        }
        else
        {
            Destroy(this);
        }

        if (!beardLadySB || !fatLadySB || !fireEaterSB || !jugglerSB)
        {
            TDS_CustomDebug.CustomDebugLogError("Missing player's selection button ! Self-destruction of the UIManager");
            Destroy(this);
        }

        if (!mainPlayerH || !mainPlayerP || !otherPlayersHParent)
        {
            TDS_CustomDebug.CustomDebugLogError("Missing player's health refrence ! Self-destruction of the UIManager");
            Destroy(this);
        }

        beardLadySB.onClick.AddListener(() => TDS_GameManager.Instance.Spawn(PlayerCharacter.BeardLady));
        fatLadySB.onClick.AddListener(() => TDS_GameManager.Instance.Spawn(PlayerCharacter.FatLady));
        fireEaterSB.onClick.AddListener(() => TDS_GameManager.Instance.Spawn(PlayerCharacter.FireEater));
        jugglerSB.onClick.AddListener(() => TDS_GameManager.Instance.Spawn(PlayerCharacter.Juggler));

        beardLadySB.interactable = false;
        fatLadySB.interactable   = false;
        fireEaterSB.interactable = false;
        jugglerSB.interactable   = false;

        if (!animator)
        {
            animator = GetComponent <Animator>();
        }

        if (quittingButton && TDS_GameManager.Instance)
        {
            quittingButton.onClick.AddListener(() => Application.Quit());
        }
    }
Ejemplo n.º 5
0
    protected virtual void DestroyThrowable()
    {
        TDS_CustomDebug.CustomDebugLog($"Destroy throwable => {name}");

        Destroy(gameObject);
    }