Exemplo n.º 1
0
    /// <summary>
    /// Let a character pickup the object.
    /// </summary>
    /// <param name="_owner">Character attempting to pick up the object.</param>
    /// <returns>Returns true is successfully picked up the object, false if a issue has been encountered.</returns>
    public virtual bool PickUp(TDS_Character _owner)
    {
        if (isHeld || owner)
        {
            return(false);
        }

        isHeld = true;
        owner  = _owner;
        owner.SetThrowable(this);

        if (PhotonNetwork.isMasterClient)
        {
            if (hitBox.IsActive)
            {
                hitBox.Desactivate();
            }

            // Pickup the throwable for other players
            TDS_RPCManager.Instance.RPCPhotonView.RPC("CallMethodOnline", PhotonTargets.Others, TDS_RPCManager.GetInfo(photonView, GetType(), "PickUp"), new object[] { _owner.PhotonID });
        }

        gameObject.layer = _owner.gameObject.layer;

        if (shadow && !shadow.activeInHierarchy)
        {
            shadow.SetActive(true);
        }
        rigidbody.isKinematic = true;
        collider.enabled      = false;

        return(true);
    }
Exemplo n.º 2
0
 /// <summary>
 /// Resets this throwable parameters, when hitting something or colliding after a throw.
 /// </summary>
 protected virtual void ResetThrowable()
 {
     LoseDurability();
     hitBox.Desactivate();
     owner            = null;
     gameObject.layer = LayerMask.NameToLayer("Object");
 }
Exemplo n.º 3
0
    /// <summary>
    /// Activates the hit box.
    /// When activated, produces the effect of the given attack to any <see cref="TDS_Damageable"/> in <see cref="collider"/> zone whose layer is in <see cref="WhatHit"/>.
    /// </summary>
    /// <param name="_attack">Attack used to hit what is in the hit box.</param>
    /// <param name="_owner">The person who attack.</param>
    /// <param name="_hittableTags">Tags to hit.</param>
    public void Activate(TDS_Attack _attack, TDS_Character _owner, Tag[] _hittableTags)
    {
        Owner = _owner;
        HittableTags.ObjectTags = _hittableTags;

        Activate(_attack);
    }
Exemplo n.º 4
0
    // OnStateEnter is called when a transition starts and the state machine starts to evaluate this state
    //override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    //{
    //
    //}

    // OnStateUpdate is called on each Update frame between OnStateEnter and OnStateExit callbacks
    //override public void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    //{
    //
    //}

    // OnStateExit is called when a transition ends and the state machine finishes evaluating this state
    override public void OnStateExit(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    {
        if (!character)
        {
            character = animator.GetComponent <TDS_Character>();
        }
        character.GetUp();
    }
Exemplo n.º 5
0
    /* TDS_BottomLimit :
     *
     *	#####################
     *	###### PURPOSE ######
     *	#####################
     *
     *	[PURPOSE]
     *
     *	#####################
     *	####### TO DO #######
     *	#####################
     *
     *	[TO DO]
     *
     *	#####################
     *	### MODIFICATIONS ###
     *	#####################
     *
     *	Date :			[DATE]
     *	Author :		[NAME]
     *
     *	Changes :
     *
     *	[CHANGES]
     *
     *	-----------------------------------
     */

    #region Methods

    #region Original Methods
    /// <summary>
    /// Reset the character position if it falls out of the bounds
    /// </summary>
    /// <param name="_character">Reset character</param>
    private void ResetCharacterPosition(TDS_Character _character)
    {
        Rigidbody _r = _character.GetComponent <Rigidbody>();

        _r.isKinematic = true;
        _r.velocity    = Vector3.zero;
        _character.transform.position = new Vector3(_character.transform.position.x, .5f, _character.transform.position.z);
        _r.isKinematic = false;
    }
Exemplo n.º 6
0
 /// <summary>
 /// Set the owner of the lifebar
 /// Link Destroy method on the event OnDie of the owner
 /// Set the follow boolean on true and get an offset
 /// </summary>
 /// <param name="_owner">Owner of the life bar</param>
 /// <param name="_offset">Offset from the owner</param>
 /// <param name="_hasToFollow">Does the lifebar has to follow its owner</param>
 public void SetOwner(TDS_Character _owner, Vector3 _offset)
 {
     SetOwner(_owner);
     if (owner is TDS_Enemy)
     {
         offset       = _offset;
         owner.OnDie += DestroyLifeBar;
     }
 }
Exemplo n.º 7
0
    private void OnCollisionEnter(Collision _collider)
    {
        if (!PhotonNetwork.isMasterClient || !_collider.gameObject.GetComponent <TDS_Character>())
        {
            return;
        }
        TDS_Character _character = _collider.gameObject.GetComponent <TDS_Character>();

        ResetCharacterPosition(_character);
    }
Exemplo n.º 8
0
 /// <summary>
 /// Set all fill amount to 1
 /// </summary>
 public virtual void ResetLifeBar()
 {
     if (foregroundFilledImage)
     {
         foregroundFilledImage.fillAmount = 1;
     }
     if (filledImage)
     {
         filledImage.fillAmount = 1;
     }
     owner = null;
     gameObject.SetActive(false);
 }
 /// <summary>
 /// Set the owner and add the methods on the linked events
 /// </summary>
 /// <param name="_owner"></param>
 public override void SetOwner(TDS_Character _owner)
 {
     if (_owner is TDS_FatLady)
     {
         base.SetOwner(_owner);
         if (PhotonNetwork.offlineMode || TDS_GameManager.LocalPlayer == PlayerType.FatLady)
         {
             feedingStatusBar.gameObject.SetActive(true);
             ((TDS_FatLady)_owner).OnAteSnack        += StartFeedingBar;
             ((TDS_FatLady)_owner).OnRestauringSnack += SetFeedingBarFilledValue;
             ((TDS_FatLady)_owner).OnRestauredSnack  += ResetFeedingBar;
             return;
         }
         feedingStatusBar.gameObject.SetActive(false);
     }
 }
    //[SerializeField] private float fillingTimer = .25f;
    #endregion

    #region Methods

    #region Original Methods
    /// <summary>
    /// Set the owner and add the methods on the linked events
    /// </summary>
    /// <param name="_owner"></param>
    public override void SetOwner(TDS_Character _owner)
    {
        if (_owner is TDS_BeardLady)
        {
            base.SetOwner(_owner);
            if (!beardStateBar)
            {
                return;
            }
            if (PhotonNetwork.offlineMode || TDS_GameManager.LocalPlayer == PlayerType.BeardLady)
            {
                beardStateBar.gameObject.SetActive(true);
                ((TDS_BeardLady)_owner).OnBeardStateChanged += ChangeBeardState;
                return;
            }
            beardStateBar.gameObject.SetActive(false);
        }
    }
Exemplo n.º 11
0
    /// <summary>
    /// Throw the object in a direction with a given velocity
    /// </summary>
    /// <param name="_velocity"></param>
    public virtual void Throw(Vector3 _velocity, int _bonusDamages = 0)
    {
        if (!isGrab || !isThrowable)
        {
            return;
        }

        gameObject.layer = LayerMask.NameToLayer("Object");

        rigidbody.isKinematic = false;
        transform.SetParent(null, true);

        rigidbody.velocity = _velocity;
        bonusDamage        = _bonusDamages;

        bearer   = null;
        isGrab   = false;
        isThrown = true;
    }
    /// <summary>
    /// Let a character pickup the object.
    /// </summary>
    /// <param name="_owner">Character attempting to pick up the object.</param>
    /// <returns>Returns true is successfully picked up the object, false if a issue has been encountered.</returns>
    public override bool PickUp(TDS_Character _owner)
    {
        if (!base.PickUp(_owner))
        {
            return(false);
        }

        detector.gameObject.SetActive(false);

        SetAnimation(2);

        if (fleeCoroutine != null)
        {
            StopCoroutine(fleeCoroutine);
            fleeCoroutine = null;
        }

        return(true);
    }
Exemplo n.º 13
0
    /// <summary>
    /// Throw the object in the direction of the facing side
    /// </summary>
    /// <param name="_facingSide">Facing side to look at</param>
    public virtual void Throw(FacingSide _facingSide, int _bonusDamages = 0)
    {
        if (!isGrab)
        {
            return;
        }

        gameObject.layer = LayerMask.NameToLayer("Object");

        rigidbody.isKinematic = false;
        transform.SetParent(null, true);

        Vector3 _force = Vector3.up;

        switch (_facingSide)
        {
        case FacingSide.Face:
            _force += -Vector3.forward;
            break;

        case FacingSide.Left:
            _force += -Vector3.right;
            break;

        case FacingSide.Right:
            _force += Vector3.right;
            break;

        case FacingSide.Back:
            _force += Vector3.forward;
            break;

        default:
            break;
        }

        rigidbody.velocity = _force * throwForce;
        bonusDamage        = _bonusDamages;

        bearer   = null;
        isGrab   = false;
        isThrown = true;
    }
    /// <summary>
    /// Let a character pickup the object.
    /// </summary>
    /// <param name="_owner">Character attempting to pick up the object.</param>
    /// <returns>Returns true is successfully picked up the object, false if a issue has been encountered.</returns>
    public override bool PickUp(TDS_Character _owner)
    {
        if (!base.PickUp(_owner))
        {
            return(false);
        }

        if (!hasBeenHeld)
        {
            hasBeenHeld = true;
            if (sprite.maskInteraction != SpriteMaskInteraction.None)
            {
                sprite.maskInteraction = SpriteMaskInteraction.None;
            }
            OnGrabbedFirstTime.Invoke();
        }

        return(true);
    }
Exemplo n.º 15
0
    public virtual bool Grab(TDS_Character _bearer)
    {
        if (!isThrowable || isGrab)
        {
            return(false);
        }

        gameObject.layer      = LayerMask.NameToLayer("Player");
        rigidbody.isKinematic = true;
        transform.position    = _bearer.transform.position + Vector3.up;
        transform.SetParent(_bearer.transform, true);
        isGrab = true;

        if (_bearer is TDS_Player)
        {
            wasGrabByPlayer = true;
        }

        bearer = _bearer;

        return(true);
    }
Exemplo n.º 16
0
    /// <summary>
    /// Drop the object from the character who was carring it.
    /// </summary>
    public virtual void Drop()
    {
        if (!isHeld)
        {
            return;
        }

        if (owner.photonView.isMine)
        {
            // Drop the throwable for other players
            TDS_RPCManager.Instance.RPCPhotonView.RPC("CallMethodOnline", PhotonTargets.Others, TDS_RPCManager.GetInfo(photonView, GetType(), "Drop"), new object[] { transform.position.x, transform.position.y, transform.position.z });
        }

        rigidbody.isKinematic = false;
        transform.SetParent(null, true);
        collider.enabled = true;
        isHeld           = false;

        owner.RemoveThrowable();
        owner = null;

        gameObject.layer = LayerMask.NameToLayer("Object");
    }
Exemplo n.º 17
0
 /// <summary>
 /// Stop the coroutine that fill the life bar and destroy the game object
 /// </summary>
 public virtual void DestroyLifeBar()
 {
     owner = null;
     gameObject.SetActive(false);
 }
Exemplo n.º 18
0
 public override void SetOwner(TDS_Character _owner)
 {
     base.SetOwner(_owner);
 }
Exemplo n.º 19
0
    public override void SetOwner(TDS_Character _owner)
    {
        base.SetOwner(_owner);

        TDS_Player _player = (TDS_Player)_owner;

        if (comboCounter)
        {
            if (_player)
            {
                if ((!PhotonNetwork.offlineMode && TDS_GameManager.LocalPlayer == playerType) || PhotonNetwork.offlineMode)
                {
                    ((TDS_Player)_owner).HitBox.OnTouch += comboCounter.IncreaseCombo;
                    comboCounter.ResetComboManager();
                    comboCounter.gameObject.SetActive(true);
                    TDS_UIManager.Instance.ComboManager = comboCounter;
                }
            }
            else
            {
                comboCounter.gameObject.SetActive(false);
            }
        }

        if (!_player.photonView.isMine)
        {
            return;
        }

        // Set inputs informations
        if (_player)
        {
            bool _isController = true;

            if ((_player.Controller == TDS_GameManager.InputsAsset.Controllers[1]) || ((_player.Controller == TDS_GameManager.InputsAsset.Controllers[0]) && Input.GetJoystickNames().Length == 0))
            {
                _isController = false;
            }

            // Set throw infos
            string[] _info = null;

            if (_player.PlayerType != PlayerType.Juggler)
            {
                _info = new string[1];

                if (_isController)
                {
                    _info[0] = "Controller_B";
                }
                else
                {
                    _info[0] = "Keyboard_F";
                }

                throwObjectText.text = string.Format(throwObjectText.text, $"<sprite name={_info[0]}>");
            }
            else
            {
                _info = new string[2];

                if (_isController)
                {
                    _info[0] = "Controller_LT";
                    _info[1] = "Controller_RT";
                }
                else
                {
                    _info[0] = "Keyboard_Ctrl";
                    _info[1] = "Keyboard_Shift";
                }

                throwObjectText.text = string.Format(throwObjectText.text, $"<sprite name={_info[0]}>", $"<sprite name={_info[1]}>");
            }

            // Set interact button
            _player.InteractionBox.InteractText.text = $"<sprite name={(_isController ? "Controller_B" : "Keyboard_F")}>";

            // Set button to show / hide how to play
            showHowToPlayText.text = string.Format(showHowToPlayText.text, $"<sprite name={(_isController ? "Controller_Select" : "Keyboard_Tab")}>");

            // Set how to play infos
            switch (_player.PlayerType)
            {
            case PlayerType.BeardLady:
                // Nothing to change here
                break;

            case PlayerType.FatLady:
                _info = new string[2];

                if (_isController)
                {
                    _info[0] = "Controller_Y";
                    _info[1] = "Controller_LB";
                }
                else
                {
                    _info[0] = "Keyboard_A";
                    _info[1] = "Keyboard_R";
                }

                howToPlayText.text = string.Format(howToPlayText.text, $"<sprite name={_info[0]}>", $"<sprite name={_info[1]}>");
                break;

            case PlayerType.FireEater:
                _info = new string[2];

                if (_isController)
                {
                    _info[0] = "Controller_X";
                    _info[1] = "Controller_Y";
                }
                else
                {
                    _info[0] = "Keyboard_E";
                    _info[1] = "Keyboard_A";
                }

                howToPlayText.text = string.Format(howToPlayText.text, $"<sprite name={_info[0]}>", $"<sprite name={_info[1]}>");
                break;

            case PlayerType.Juggler:
                _info = new string[5];

                if (_isController)
                {
                    _info[0] = "Controller_B";
                    _info[1] = "Controller_LT";
                    _info[2] = "Controller_Joystick";
                    _info[3] = "Controller_RT";
                    _info[4] = "Controller_DPadX";
                }
                else
                {
                    _info = new string[7];

                    _info[0] = "Keyboard_F";
                    _info[1] = "Keyboard_Ctrl";
                    _info[2] = "Keyboard_J> & <sprite name=Keyboard_L";
                    _info[3] = "Keyboard_Shift";
                    _info[4] = "Keyboard_1> & <sprite name=Keyboard_2";
                }

                howToPlayText.text = string.Format(howToPlayText.text, $"<sprite name={_info[0]}>", $"<sprite name={_info[1]}>", $"<sprite name={_info[2]}>", $"<sprite name={_info[3]}>", $"<sprite name={_info[4]}>");
                break;

            default:
                break;
            }
        }

        if (howToPlayAnchor)
        {
            howToPlayAnchor.SetActive(true);
        }
        if (howToPlayInfo && !howToPlayInfo.activeInHierarchy && (TDS_GameManager.CurrentSceneIndex == 1))
        {
            howToPlayInfo.SetActive(true);
        }
    }
Exemplo n.º 20
0
 /// <summary>
 /// Activates the hit box.
 /// When activated, produces the effect of the given attack to any <see cref="TDS_Damageable"/> in <see cref="collider"/> zone whose layer is in <see cref="WhatHit"/>.
 /// </summary>
 /// <param name="_attack">Attack used to hit what is in the hit box.</param>
 /// <param name="_owner">The person who attack.</param>
 public void Activate(TDS_Attack _attack, TDS_Character _owner)
 {
     Owner = _owner;
     Activate(_attack);
 }
Exemplo n.º 21
0
 /// <summary>
 /// Set the owner of the lifebar
 /// Link Destroy method on the event OnDie of the owner
 /// </summary>
 /// <param name="_owner">Owner of the life bar</param>
 public virtual void SetOwner(TDS_Character _owner)
 {
     owner = _owner;
 }