Пример #1
0
    public void FixedUpdate()
    {
        if (pawn.BuilderHealthScript.IsAlive)
        {
            // ** Commit actions based on input ** //

            // Movement
            Vector3 moveDirection = new Vector3(xAxisMove, 0, yAxisMove).normalized;
            Vector3 moveForce     = (moveDirection * pawn.MovementForce) * (1.0f - pawn.MovementPenaltyPercent);
            this.gameObject.rigidbody.drag = pawn.MovementDrag;
            this.gameObject.rigidbody.AddForce(moveForce);

            // Aiming
            Vector3 targetLookDirection  = new Vector3(xAxisLook, 0, yAxisLook).normalized;
            Vector3 currentLookDirection = Vector3.RotateTowards(this.transform.forward, targetLookDirection, pawn.LookForce * Time.fixedDeltaTime, 0.0f);
            this.gameObject.transform.rotation = Quaternion.LookRotation(currentLookDirection);

            // Buttons
            if (isPickupButtonPressed)
            {
                if (pawn.IsHoldingItem || pawn.IsHoldingPlayer)
                {
                    pawn.DropItem();
                }
                else
                {
                    pawn.PickupItem();
                }
            }

            if (isFireButtonPressed)
            {
                pawn.Fire();
            }
            else
            {
                pawn.CeaseFire();
            }
        }
        else
        {
            if (pawn.IsBeingHeld)
            {
                this.transform.position = pawn.CurrentOwner.CarryPoint.transform.position;
                this.transform.rotation = pawn.CurrentOwner.CarryPoint.transform.rotation;
            }
        }
    }
Пример #2
0
    protected override void OnTriggerEnter(Collider aCollider)
    {
        if (aCollider.gameObject.GetComponent <BuilderPawn>() != null)
        {
            BuilderPawn builderPawn = aCollider.gameObject.GetComponent <BuilderPawn>();

            if (builderPawn.BuilderHealthScript.IsAlive)
            {
                if (builderPawn.IsHoldingPlayer)
                {
                    builderPawn.CurrentHeldPlayer.BuilderHealthScript.Respawn();

                    builderPawn.DropItem();
                }
                else
                {
                    builderPawn.NearbyBuildings.Add(this);
                }
            }
        }
    }