コード例 #1
0
ファイル: FarmerController.cs プロジェクト: Tubocass/NNGather
    public override void OnCollisionEnter(Collision bang)
    {
        if (!isServer)
        {
            return;
        }

        if (bang.collider.CompareTag("Food"))
        {
            FoodObject ot = bang.gameObject.GetComponent <FoodObject>();
            if (ot != null && ot.CanBeTargetted)
            {
                if (IsTargetingFood() || CanTargetFood())
                {
                    if (IsTargetingFood() && ot.Id != targetedFood.Id)
                    {
                        return;
                    }
                    targetedFood = null;
                    carriedFood  = ot;
                    ot.Attach(this.gameObject, nose);
//					childTransform.enabled = true;
//					childTransform.target = ot.transform;
                    foodLoc = ot.Location;
                    StartCoroutine(ReturnToHome());
                }
            }
        }

        if (IsCarryingFood() && bang.collider.tag == "MoM")
        {
            MoMController bangMoM = bang.gameObject.GetComponent <MoMController>();
            if (bangMoM.unitID == myMoM.unitID)
            {
                bangMoM.AddFoodLocation(foodLoc);
//				childTransform.target = null;
//				childTransform.enabled = false;
                carriedFood.Destroy();
                carriedFood = null;
                bReturning  = false;
            }
        }
    }
コード例 #2
0
ファイル: SpriteDrone.cs プロジェクト: Tubocass/NNGather
    public void OnCollisionEnter(Collision bang)
    {
        if (!isServer)
        {
            return;
        }

        if (bang.collider.CompareTag("Food"))
        {
            FoodObject ot = bang.gameObject.GetComponent <FoodObject>();
            if (ot != null && ot.CanBeTargetted)
            {
                if (IsTargetingFood() || CanTargetFood())
                {
                    if (IsTargetingFood() && ot.Id != targetedFood.Id)
                    {
                        return;
                    }
                    targetedFood = null;
                    carriedFood  = ot;
                    ot.Attach(this.gameObject, new Vector3(0, 0, 1));
                    foodLoc = ot.Location;
                    StartCoroutine(ReturnToHome());
                }
            }
        }
        if (IsCarryingFood() && bang.collider.tag == "MoM")
        {
            Interact bangMoM = bang.gameObject.GetComponent <Interact>();
            if (bangMoM.unitID == myMoM.unitID)
            {
                //bangMoM.AddFoodLocation(foodLoc);
                carriedFood.Destroy();
                carriedFood = null;
                bReturning  = false;
            }
        }
    }