コード例 #1
0
ファイル: Player.cs プロジェクト: aproctor/Donk
    void UpdateDirection()
    {
        //Convert Incontrol vectors to movement directions in 3d space
        this.moveDirection = new Vector3(device.Direction.Vector.x, 0, device.Direction.Vector.y).normalized;
        this.aimDirection  = new Vector3(device.RightStick.Vector.x, 0f, device.RightStick.Vector.y);

        if (this.turret && aimDirection.sqrMagnitude > this.fireSensitivity)
        {
            Quaternion quat = Quaternion.LookRotation(aimDirection, Vector3.up);
            this.turret.transform.rotation = quat;
        }

        if (latchedObject != null)
        {
            float moveScale = latchedMoveSpeed;

            BigEgg egg = latchedObject.GetComponent <BigEgg>();
            if (egg != null)
            {
                moveScale = moveScale * egg.numLatchers;
            }

            this.latchedObject.MovePosition(this.latchedObject.position + moveDirection * Time.deltaTime * this.currentSpeed * moveScale);
        }
        else
        {
            //Move self
            this.GetComponent <Rigidbody>().MovePosition(this.transform.position + moveDirection * Time.deltaTime * this.currentSpeed);
        }

        this.characterAnimator.SetFloat("Speed", this.moveDirection.sqrMagnitude);   //That's not right, we should actually pass the player speed
    }
コード例 #2
0
ファイル: Player.cs プロジェクト: aproctor/Donk
    void PrimaryAction()
    {
        Collider[] possibleObjects = Physics.OverlapBox(this.InteractTrigger.bounds.center, this.InteractTrigger.bounds.extents);

        for (int i = 0; i < possibleObjects.Length; i++)
        {
            BigEgg egg = possibleObjects[i].gameObject.GetComponent <BigEgg>();
            if (egg != null && (this.latchedObject == null))
            {
                LatchOnto(egg.GetComponent <Rigidbody>());
                ++egg.numLatchers;
                break;
            }

            Chicken chicken = possibleObjects[i].gameObject.GetComponent <Chicken>();
            if (chicken != null && (this.chickensInStomach.Count < this.maxChickensInStomach))
            {
                EatChicken(chicken);
                break;
            }

            Shop shop = possibleObjects[i].gameObject.GetComponent <Shop>();
            if (shop != null && shop.open && this.gold >= shop.goldCost)
            {
                this.gold -= shop.goldCost;
                this.AddAbility(shop.abilityPrefab);
                shop.ItemPurchased();
            }
        }
    }
コード例 #3
0
ファイル: Crossbow.cs プロジェクト: aproctor/Donk
    public void HitTarget(Damagable target)
    {
        BigEgg egg       = target.GetComponent <BigEgg> ();
        Player hitPlayer = target.gameObject.GetComponent <Player>();

        //This logic could be drastically simplified just by checking the layer mask, but that's not working and this is a jam so f**k it
        if (egg == null && (hitPlayer == null || (hitPlayer.team != this.player.team)))
        {
            this.ApplyDamage(target, this.damageAmount);
        }
    }