// this function will be called upon powerup use / collision after trown
    public override void OnActivate()
    {
        //Make sure powerups can only be activated once!
        if (activated)
        {
            return;
        }
        activated = true;
        ChadControls otherChad = null;

        if (_LastCollider)
        {
            otherChad = _LastCollider.gameObject.GetComponent <ChadControls>();
        }

        if (otherChad)
        {
            // rustle his jimmies
            Ragdoll.ImpactParams param = new Ragdoll.ImpactParams(gameObject.transform.position, Vector3.Zero, 0.0f);
            param.bodyPartFactor[(int)Ragdoll.BODYPART.SPINE]           = 0.88f;
            param.bodyPartFactor[(int)Ragdoll.BODYPART.RIGHT_LOWER_LEG] = 10.0f;
            param.bodyPartFactor[(int)Ragdoll.BODYPART.LEFT_LOWER_LEG]  = 5.0f;
            param.bodyPartFactor[(int)Ragdoll.BODYPART.HEAD]            = -2.0f;
            param.force = otherChad.transform.forward * otherChad.CurrentVelocity.y * 50.0f;
            otherChad.ActivateRagdoll(3.0f, param);
            SlipSound.Play();
        }

        Explosion();
    }
Example #2
0
    //public override void OnCollisionEnter(Collider collider)
    //{
    //    //Check if colliding with a player
    //    ChadControls otherChad = collider.gameObject.GetComponent<ChadControls>();
    //    if (!otherChad)
    //    {
    //        base.OnCollisionEnter(collider);
    //    }
    //    else
    //    {
    //        ChadControls localChad = MatchSystem.instance.LocalChad;

    //        TEAM_TYPE playerTeam = MatchSystem.instance.GetPlayerTeam(ObjectOwner.gameObject);
    //        TEAM_TYPE otherPlayerTeam = MatchSystem.instance.GetPlayerTeam(collider.gameObject);

    //        if (localChad && (otherPlayerTeam != playerTeam))
    //            base.OnCollisionEnter(collider);
    //    }
    //}

    // this function will be called upon powerup use / collision after trown
    public override void OnActivate()
    {
        //Make sure powerups can only be activated once!
        if (activated)
        {
            return;
        }
        activated = true;
        // boom particles, Gustav do your magic, sprinkla lite magic till boisen
        Explosion();

        ChadControls localChad = MatchSystem.instance.LocalChad;

        TEAM_TYPE playerTeam      = MatchSystem.instance.GetPlayerTeam(ObjectOwner.gameObject);
        TEAM_TYPE otherPlayerTeam = MatchSystem.instance.GetPlayerTeam(localChad.gameObject);

        if (localChad && otherPlayerTeam != playerTeam)
        {
            float distance = Vector3.Distance(localChad.transform.position, transform.position);
            if (distance < ExplosionRadius)
            {
                Vector3 forceDir = localChad.transform.position - transform.position;
                forceDir.Normalize();
                forceDir.y += 3.0f;


                float   distForce          = ExplosionRadius - distance;
                Vector3 force              = forceDir * ExplosionForce * distForce;
                Ragdoll.ImpactParams param = new Ragdoll.ImpactParams(gameObject.transform.position, force, 0.0f);
                localChad.ActivateRagdoll(2.0f, param);
                AnnouncerSoundManager.Instance.Announce(ANNOUNCEMENT_TYPE.EXPLODED);
            }
        }
    }
Example #3
0
 public void RPCLocalActivateRagdoll(float duration, Ragdoll.ImpactParams param)
 {
     if (MatchSystem.instance.LocalChad)
     {
         MatchSystem.instance.LocalChad.LocalActivateRagdoll(duration, param);
     }
 }
Example #4
0
    IEnumerator StartRagdoll(float duration, Ragdoll.ImpactParams param)
    {
        AnnouncerSoundManager.Instance.Announce(ANNOUNCEMENT_TYPE.TACKLED);
        State = STATE.RAGDOLL;
        EnableRagdoll();
        Ragdoll.AddForce(param);
        if (isOwner)
        {
            yield return(new WaitForSeconds(duration));

            Debug.Log("Deactivating them ragdoll bois was good");
            while (Ragdoll.DistanceToWorld() >= 0.75f) // can trigger mid air atm, check if ray hits ground and not chad
            {
                yield return(null);
            }
            //Debug.Log("The ground has been reached.");
            yield return(new WaitForSeconds(1));

            State             = STATE.CHADING;
            CurrentVelocity.y = BaseSpeed;
        }
        else
        {
            yield return(null);
        }
    }
Example #5
0
    public override void OnCollisionStay(Collider collider)
    {
        if (MatchSystem.instance && isOwner && State != STATE.RAGDOLL && !Locked)
        {
            ChadControls otherChad = collider.gameObject.GetComponent <ChadControls>();

            if (otherChad)
            {
                float modifiedBaseSpeed = PickedUpObject ? PickedUpObject.MovementSpeedModifier * BaseSpeed : BaseSpeed;
                float TheirVelocity     = otherChad.CurrentVelocity.y;//Length();
                if (MatchSystem.instance.GetPlayerTeam(collider.gameObject) == MatchSystem.instance.GetPlayerTeam(this.gameObject))
                {
                    //Debug.Log("Trying to tackle player on same team, you baka.");
                }
                else if (otherChad.CanBeTackled && ((CurrentVelocity.y /*Length()*/ > TackleThreshold || (PickedUpObject && CurrentVelocity.y > BaseSpeed)) && CurrentVelocity.y /*Length()*/ >= TheirVelocity))
                {
                    Debug.Log("They tackled with: " + TheirVelocity + "(Forward: " + otherChad.CurrentVelocity.y + ", Strafe: " + otherChad.CurrentVelocity.x + ")");
                    Debug.Log("You tackled with: " + CurrentVelocity.y /*Length()*/ + "(Forward: " + CurrentVelocity.y + ", Strafe: " + CurrentVelocity.x + ")");

                    // Activate ragdoll
                    Vector3 force = (transform.forward + Vector3.Up * 0.5f) * ImpactFactor * CurrentVelocity.Length();
                    Ragdoll.ImpactParams param = new Ragdoll.ImpactParams(otherChad.gameObject.transform.position, force, 0.5f);
                    param.bodyPartFactor[(int)Ragdoll.BODYPART.RIGHT_LOWER_LEG] = 1.3f;
                    param.bodyPartFactor[(int)Ragdoll.BODYPART.LEFT_LOWER_LEG]  = 1.3f;
                    otherChad.ActivateRagdoll(MinimumRagdollTimer, param);
                    AnnouncerSoundManager.Instance.Announce(ANNOUNCEMENT_TYPE.TACKLED);

                    NetPlayer.HasTackled += 1;
                    CurrentVelocity.y     = modifiedBaseSpeed;
                }
            }
        }
    }
Example #6
0
 /* Call for activating ragdoll
  */
 public void ActivateRagdoll(float duration, Ragdoll.ImpactParams param)
 {
     if (!isOwner)
     {
         NetPeer peerThatOwnsThisPlayer = MatchSystem.instance.Scene.Players.FirstOrDefault(player => player.Value == Identity).Key;
         if (peerThatOwnsThisPlayer != null)
         {
             MatchSystem.instance.SendRPC(peerThatOwnsThisPlayer, -1, "RPCLocalActivateRagdoll", duration, param);
         }
         RPCStartRagdoll(duration, param);
     }
     else
     {
         LocalActivateRagdoll(duration, param);
     }
     Ragdoll.Smack();
 }
Example #7
0
    public void RPCStartRagdoll(float duration, Ragdoll.ImpactParams param)
    {
        if (isOwner && PickedUpObject && PickedUpObject.DropOnRagdoll)
        {
            if (typeof(Powerup).IsAssignableFrom(PickedUpObject.GetType()))
            {
                Debug.Log("remove");
                (PickedUpObject as Powerup).Remove();
            }
            else
            {
                PickedUpObject.Drop();
                Debug.Log("drop");
            }
        }

        if (State != STATE.RAGDOLL)
        {
            Ragdolling = StartRagdoll(duration, param);
            StartCoroutine(Ragdolling);
            //if(isOwner)
            //    Camera.InitFreeLookCamera();
        }
    }
Example #8
0
 private void LocalActivateRagdoll(float duration, Ragdoll.ImpactParams param)
 {
     SendRPC("RPCStartRagdoll", duration, param);
     RPCStartRagdoll(duration, param);
 }
Example #9
0
    public override void Update()
    {
        if (isOwner)
        {
            // Toy solider powerup
            if (ToySoldierAffected)
            {
                if (ToySoldierModifier == null)
                {
                    ToySoldierModifier = ToySoldierRoutine();
                    StartCoroutine(ToySoldierModifier);
                }
            }

            DivingTimer  += Time.DeltaTime;
            JumpingTimer += Time.DeltaTime;

            Direction = new Vector3(0, 0, 0);
            if (State != STATE.RAGDOLL && State != STATE.DANCING)
            {
                if ((CameraMaster.instance.GetState() != CAM_STATE.EXIT_MENU) && (CameraMaster.instance.GetState() != CAM_STATE.OPTIONS_MENU))
                {
                    HandleKeyboardInput();
                    HandleMouseInput();
                }

                AirHandling();
            }
            //Accelerate fake gravity as it felt too low, playtest
            if (!OnGround() && rBody.LinearVelocity.y < 0 && rBody.LinearVelocity.y > -5.9f && JumpingTimer > 1)
            {
                rBody.LinearVelocity = rBody.LinearVelocity = Vector3.Transform(new Vector3(rBody.LinearVelocity.x, rBody.LinearVelocity.y - 2, rBody.LinearVelocity.z), rBody.Rotation);
            }
        }
        StateMachine();

        if (rBody != null)
        {
            rBody.IsKinematic = !isOwner;
        }

        /* Enter leave ragdoll state
         */
        if (State == STATE.RAGDOLL && !Ragdoll.RagdollEnabled)
        {
            EnableRagdoll();
        }
        else if (State != STATE.RAGDOLL && Ragdoll.RagdollEnabled)
        {
            // Wait N frames before disabling ragdoll
            if (isOwner || frameRagdollDisableTick-- == 0)
            {
                DisableRagdoll();
                frameRagdollDisableTick = FRAME_TICK_WAIT_RAGDOLL;
            }
        }


#if (L_FOR_RAGDOLL)
        if (Input.GetKeyDown(Input.Keys.L))
        {
            Ragdoll.ImpactParams param = new Ragdoll.ImpactParams(gameObject.transform.position, (/*-transform.forward +*/ transform.up * 0.5f) * 200000, 1);
            ActivateRagdoll(MinimumRagdollTimer, param);
        }
        if (Input.GetKeyDown(Input.Keys.J))
        {
            Debug.Log(rBody.Position);
        }
        if (Input.GetKeyDown(Input.Keys.K))
        {
            NetPlayer.Reset();
        }
#endif

        if (Input.GetKeyDown(Input.Keys.F12))
        {
            if (PickedUpObject)
            {
                Debug.Log("Your current held item: " + PickedUpObject);
            }
            else
            {
                Debug.Log("No held item.");
            }
        }

        rBody.Friction = 0.5f;
        if (!OnGround())
        {
            rBody.Friction = 0.0f;
        }


        if (State != STATE.DIVING)
        {
            Animations.ResetTimer(STATE.DIVING, 0);
        }
    }