コード例 #1
0
    void Start()
    {
        BuildingSensor.AddBuilding(this);

        GameObject farmerPrefab = Resources.Load("Prefabs/Farmer") as GameObject;

        GameObject.Instantiate(farmerPrefab, this.transform.position, this.transform.rotation);
    }
コード例 #2
0
    public void OnBuildHouseCommandIssued()
    {
        Vector3 nearestPossibleNewHouseLocation = BuildingSensor.FindNearestBuildSpot(BuildingTypes.HOUSE, this.transform);

        if (nearestPossibleNewHouseLocation != null)
        {
            float step = this.speed * Time.deltaTime;
            this.transform.position = Vector3.MoveTowards(this.transform.position, nearestPossibleNewHouseLocation, step);
        }
    }
コード例 #3
0
    public void OnBuyWeaponCommandIssued()
    {
        Building nearestPossibleShop = BuildingSensor.FindNearest(BuildingTypes.SHOP, this.transform);

        if (nearestPossibleShop != null && nearestPossibleShop is Shop && nearestPossibleShop is MonoBehaviour)
        {
            MonoBehaviour shopBehaviour = nearestPossibleShop as MonoBehaviour;
            float         step          = this.speed * Time.deltaTime;
            this.transform.position = Vector3.MoveTowards(this.transform.position, shopBehaviour.transform.position, step);
        }
    }
コード例 #4
0
    public void OnFarmCommandIssued()
    {
        Building nearestPossibleFarm = BuildingSensor.FindNearest(BuildingTypes.FARM, this.transform);

        if (nearestPossibleFarm != null && nearestPossibleFarm is Farm && nearestPossibleFarm is MonoBehaviour)
        {
            MonoBehaviour farmBehaviour = nearestPossibleFarm as MonoBehaviour;
            float         step          = this.speed * Time.deltaTime;
            this.transform.position = Vector3.MoveTowards(this.transform.position, farmBehaviour.transform.position, step);
        }
    }
コード例 #5
0
    public bool IsBuildHouseCommandCompleted()
    {
        Vector3 nearestPossibleNewHouseLocation = BuildingSensor.FindNearestBuildSpot(BuildingTypes.HOUSE, this.transform);

        if (nearestPossibleNewHouseLocation != null)
        {
            Vector3 vectorToHouseLocation = transform.position - nearestPossibleNewHouseLocation;
            return(vectorToHouseLocation.magnitude <= 1.0f);
        }
        return(false);
    }
コード例 #6
0
    public bool IsBuyWeaponCommandCompleted()
    {
        Building nearestPossibleShop = BuildingSensor.FindNearest(BuildingTypes.SHOP, this.transform);

        if (nearestPossibleShop != null && nearestPossibleShop is Shop && nearestPossibleShop is MonoBehaviour)
        {
            MonoBehaviour shopBehaviour = nearestPossibleShop as MonoBehaviour;
            Vector3       vectorToShop  = transform.position - shopBehaviour.transform.position;
            return(vectorToShop.magnitude <= 1.0f);
        }
        return(false);
    }
コード例 #7
0
    public bool IsFarmCommandComplete()
    {
        Building nearestPossibleFarm = BuildingSensor.FindNearest(BuildingTypes.FARM, this.transform);

        if (nearestPossibleFarm != null && nearestPossibleFarm is Farm && nearestPossibleFarm is MonoBehaviour)
        {
            MonoBehaviour farmBehaviour = nearestPossibleFarm as MonoBehaviour;
            Vector3       vectorToFarm  = transform.position - farmBehaviour.transform.position;
            return(vectorToFarm.magnitude <= 1.0f);
        }
        return(false);
    }
コード例 #8
0
 void Start()
 {
     BuildingSensor.AddBuilding(this);
 }