Beispiel #1
0
 public override bool OnWrite(NetDataWriter writer, bool initialState)
 {
     writer.Put(PickedUpObject ? PickedUpObject.ID : -1);
     writer.Put((int)State);
     writer.Put(Direction);
     writer.Put(CurrentVelocity);
     writer.Put(HasThrown);
     writer.Put(CanBeTackled);
     if (!Animations)
     {
         Animations = gameObject.GetComponent <Chadimations>();
     }
     writer.Put(Animations.Throwing);
     return(true);
 }
Beispiel #2
0
    public override void OnRead(NetDataReader reader, bool initialState)
    {
        if (isOwner)
        {
            reader.GetInt();
            reader.GetInt();
            reader.GetVector3();
            reader.GetVector2();
            reader.GetBool();
            reader.GetBool();
            reader.GetBool();
            return;
        }

        int pickedUpObject = reader.GetInt();

        if (pickedUpObject >= 0)
        {
            RPCPickup(pickedUpObject);
        }
        else if (PickedUpObject)
        {
            PickedUpObject.RPCDrop();
            PickedUpObject = null;
        }


        State           = (STATE)reader.GetInt();
        Direction       = reader.GetVector3();
        CurrentVelocity = reader.GetVector2();
        HasThrown       = reader.GetBool();
        CanBeTackled    = reader.GetBool();
        if (!Animations)
        {
            Animations = gameObject.GetComponent <Chadimations>();
        }
        Animations.Throwing = reader.GetBool();
    }
Beispiel #3
0
    public override void Start()
    {
        Canvas = ChadHud.Instance.Canvas;

        // Init pick-up text and description
        PowerupPickupText          = Canvas.Add("");
        PowerupPickupText.position = new Vector2(0.4975f, 0.83f);
        PowerupPickupText.color    = Color.White; // Need black outline for better visual effect
        PowerupPickupText.origin   = new Vector2(0.5f, 0.0f);
        PowerupPickupText.outline  = true;
        PowerupPickupText.font     = PickupFont;

        State = STATE.CHADING;

        // Access rigidbody and apply
        rBody             = gameObject.GetComponent <Rigidbody>();
        rBody.IsKinematic = false;

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

        NetPlayer            = gameObject.GetComponent <NetworkPlayer>();
        rBody.Friction       = 0.99f;
        Animations           = gameObject.GetComponent <Chadimations>();
        Ragdoll              = gameObject.GetComponent <Ragdoll>();
        ragdollSync.target   = Ragdoll.GetHips().transform;
        ragdollSync.SyncMode = NetworkTransform.TransformSyncMode.SyncRigidbody;
        if (rBody != null)
        {
            rBody.IsKinematic = !isOwner;
        }
        Identity.RefreshCache();

        MinimumRagdollTimer = 2.0f;

        FirstJumpForce          = 450.0f;
        SecondJumpForce         = 350.0f;
        OriginalFirstJumpForce  = FirstJumpForce;
        OriginalSecondJumpForce = SecondJumpForce;

        // Store original values
        OriginalScale        = gameObject.transform.scale;
        OriginalAcceleration = Acceleration;
        OriginalBaseSpeed    = BaseSpeed;
        OriginalMaxSpeed     = MaxSpeed;

        CapsuleCollider capsule = gameObject.GetComponent <CapsuleCollider>();

        OrginalCapsuleCenter  = capsule.center;
        OriginalCapsuleHeight = capsule.height;
        OriginalCapsuleRadius = capsule.radius;
        OriginalMass          = rBody.Mass;

        //OriginalMaterials = gameObject.GetComponent<RenderSkinnedComponent>().materials;

        TackleThreshold = 8.5f;

        runningFastParticles = gameObject.AddComponent <ParticleEmitter>();
        Texture2D smokeTex = (Texture2D)Resources.LoadThomasPath("%THOMAS_ASSETS%/Particles/smoke_particle.png");

        if (smokeTex.height > 0)
        {
            runningFastParticles.Texture = smokeTex;
        }
        runningFastParticles.MinSize                  = 0.2f;
        runningFastParticles.MaxSize                  = 0.4f;
        runningFastParticles.EndSize                  = 0.0f;
        runningFastParticles.MinLifeTime              = 0.2f;
        runningFastParticles.MaxLifeTime              = 0.9f;
        runningFastParticles.EmissionRate             = 40;
        runningFastParticles.MinRotationSpeed         = -5.0f;
        runningFastParticles.MaxRotationSpeed         = 5.0f;
        runningFastParticles.MinSpeed                 = 0.0f;
        runningFastParticles.MaxSpeed                 = 0.0f;
        runningFastParticles.EndSpeed                 = 0.0f;
        runningFastParticles.DistanceFromSphereCenter = 0;
        runningFastParticles.Gravity                  = 0.0f;
    }