示例#1
0
    void OnTriggerEnter(Collider collider)
    {
        if (collider.gameObject.tag == "DigGround")
        {
            GameObject     digGround      = collider.gameObject;
            GroundBehavior groundVariable = digGround.GetComponent <GroundBehavior>();
            groundVariable.isPlanted = true;

            switch (seedType)
            {
            case 1:
                //Debug.Log(groundVariable.transform.position.x+" "+ groundVariable.transform.position.y+ " "+ groundVariable.transform.position.z);
                //Debug.Log(groundVariable.transform.localPosition.x + " " + groundVariable.transform.localPosition.y + " " + groundVariable.transform.localPosition.z);
                GameObject sap = Instantiate(sapling, new Vector3(0, 0, 0), Quaternion.identity);
                sap.transform.localPosition = new Vector3(groundVariable.transform.position.x + 0.25f, groundVariable.transform.position.y, groundVariable.transform.position.z - 0.25f);
                break;

            case 2:
                GameObject stalk = Instantiate(sapling, new Vector3(0, 0, 0), Quaternion.identity);
                stalk.transform.localPosition = new Vector3(groundVariable.transform.position.x + 0.25f, groundVariable.transform.position.y - 0.1f, groundVariable.transform.position.z - 0.25f);
                break;
            }

            Destroy(gameObject);
        }
    }
示例#2
0
    private void OnTriggerExit(Collider other)
    {
        GameObject otherObject = other.gameObject;

        if (otherObject.tag == "Planted" || otherObject.tag == "SpawnPoint")
        {
            Collider  collider  = GetComponent <Collider>();
            Rigidbody rigidbody = GetComponent <Rigidbody>();

            isTimerRun           = false;
            rigidbody.useGravity = true;
            collider.isTrigger   = false;
            transform.parent     = null;

            if (otherObject.tag == "Planted" && !isPicked)
            {
                GroundBehavior ground = otherObject.GetComponent <GroundBehavior>();
                ground.isReset = true;
            }
            else if (otherObject.tag == "SpawnPoint" && !isPicked)
            {
                PolyCarpicRespawn spawnPoint = otherObject.GetComponent <PolyCarpicRespawn>();
                spawnPoint.isFertile = false;
            }
            isPicked = true;
        }
    }
示例#3
0
    private void OnTriggerStay(Collider other)
    {
        GameObject otherObject = other.gameObject;

        if (otherObject.tag == "Planted")
        {
            GroundBehavior ground = otherObject.GetComponent <GroundBehavior>();
            if (ground.isWatered)
            {
                isReady = true;
                //ground.volume -= ground.maxVolume;
            }
            else
            {
                isReady = false;
            }

            if (ground.isFertilized)
            {
                isFertilized = true;
            }
            else
            {
                isFertilized = false;
            }
        }
    }
示例#4
0
 void OnTriggerEnter(Collider collider)
 {
     if (collider.gameObject.tag == "ground" && isReady)
     {
         GameObject     ground         = collider.gameObject;
         GroundBehavior groundVariable = ground.GetComponent <GroundBehavior>();
         groundVariable.isDug = true;
         isReady = false;
     }
 }
示例#5
0
    private void OnTriggerStay(Collider other)
    {
        GameObject otherObject = other.gameObject;

        if (otherObject.tag == "Planted")
        {
            GroundBehavior ground = otherObject.GetComponent <GroundBehavior>();
            if (ground.isWatered)
            {
                isReady = true;
            }

            if (ground.isFertile && !isFertilized)
            {
                valuePlant  += valuePlant * 10 / 100;
                isFertilized = true;
            }

            //Check weed
            if (ground.isWeed)
            {
                isWeed = true;
            }
            else
            {
                isWeed = false;
            }
        }
        else if (otherObject.tag == "SpawnPoint")
        {
            PolyCarpicRespawn spawnPoint = otherObject.GetComponent <PolyCarpicRespawn>();
            if (spawnPoint.isFertile && !isFertilized)
            {
                valuePlant  += valuePlant * 10 / 100;
                isFertilized = true;
            }
        }

        else if (otherObject.tag == "Mole")
        {
            Transform molePos = otherObject.GetComponent <Transform>();
            transform.position = new Vector3(transform.position.x, molePos.transform.position.y + 0.28f, transform.position.z);
        }
    }
示例#6
0
    void OnTriggerStay(Collider collider)
    {
        GameObject colObject = collider.gameObject;

        //Filling water can
        if (colObject.name == "Well")
        {
            if (currentVolume < maxVolume)
            {
                currentVolume = currentVolume + 5;
            }
            //Debug.Log("filling : " + currentVolume);
        }

        //Watering ground
        else
        {
            if (currentVolume > 0)
            {
                //Watering
                if (colObject.tag == "DigGround" || colObject.tag == "Planted")
                {
                    currentVolume = currentVolume - 1;
                    GroundBehavior groundVariable = colObject.GetComponent <GroundBehavior>();
                    groundVariable.volume = groundVariable.volume + 1;

                    if (groundVariable.volume > groundVariable.maxVolume)
                    {
                        groundVariable.isWatered = true;
                    }
                    //Debug.Log("watering: " + currentVolume);
                }
                else if (colObject.tag == "AllGround")
                {
                    currentVolume = currentVolume - 1;
                    //Debug.Log("spilling: " + currentVolume);
                }
            }
        }
    }
        public override async Task ExecuteAsync(ExecutionContext context, ExecutionBranchContext branchContext)
        {
            await base.ExecuteAsync(context, branchContext);

            MovementType = (MovementType)context.Reader.Read <uint>();

            switch (MovementType)
            {
            case MovementType.Ground:
                await GroundBehavior.ExecuteAsync(context, branchContext);

                return;

            case MovementType.Jump:
                await JumpBehavior.ExecuteAsync(context, branchContext);

                return;

            case MovementType.Falling:
                await FallingBehavior.ExecuteAsync(context, branchContext);

                return;

            case MovementType.DoubleJump:
                await DoubleJumpBehavior.ExecuteAsync(context, branchContext);

                return;

            case MovementType.Jetpack:
                await JetpackBehavior.ExecuteAsync(context, branchContext);

                return;

            case MovementType.Stunned:
                return;

            default:
                throw new Exception($"Invalid {nameof(MovementType)}! Got {MovementType}!");
            }
        }
        public override async Task ExecuteAsync(ExecutionContext context, ExecutionBranchContext branchContext)
        {
            await base.ExecuteAsync(context, branchContext);

            MovementType = (MovementType)context.Reader.Read <uint>();

            context.Writer.Write((uint)MovementType);

            switch (MovementType)
            {
            case MovementType.Ground:
                await GroundBehavior.ExecuteAsync(context, branchContext);

                return;

            case MovementType.Jump:
                await JumpBehavior.ExecuteAsync(context, branchContext);

                return;

            case MovementType.Falling:
                await FallingBehavior.ExecuteAsync(context, branchContext);

                return;

            case MovementType.DoubleJump:
                await DoubleJumpBehavior.ExecuteAsync(context, branchContext);

                return;

            case MovementType.Jetpack:
                await JetpackBehavior.ExecuteAsync(context, branchContext);

                return;

            default:
                return;
            }
        }