コード例 #1
0
ファイル: JimAI.cs プロジェクト: B-Noone/Servare
 void ErrorCheck()
 {
     if ((builtSomething == true && moving == true) && (BuildingToConstruct == null || BuildingRequirements == null))
     {
         moving = false;
         BuildingToConstruct  = null;
         builtSomething       = false;
         BuildingRequirements = null;
     }
     if (Objective == null)
     {
         moving = false;
     }
 }
コード例 #2
0
ファイル: JimAI.cs プロジェクト: B-Noone/Servare
    void BuildConstruct()
    {
        //Debug.Log("Build Construct");
        BuildingRequirements = BuildingToConstruct.GetComponent <BuildingConstruct>();
        if (inventory != resourceSearch.Wood && inventory != resourceSearch.Stone)
        {
            if (BuildingRequirements.wood > 0)
            {
                //Debug.Log("Jim LOOKS FOR WOOD");
                if (StockpileScript.wood <= 0)
                {
                    //Debug.Log("Jim LOOKS FOR TREES");
                    //Debug.Log("Build Construct: Wood");
                    objFind       = "Tree";
                    currentAction = action.Gather;
                    currentSearch = resourceSearch.Wood;
                }
                else if (StockpileScript.wood > 0)
                {
                    //Debug.Log("Jim LOOKS FOR WOODPILE");
                    currentAction = action.Collect;
                    currentSearch = resourceSearch.Wood;
                }
            }

            else if (BuildingRequirements.stone > 0)
            {
                if (StockpileScript.stone <= 0)
                {
                    //Debug.Log("Build Construct: Stone");
                    objFind       = "Rock";
                    currentAction = action.Gather;
                    currentSearch = resourceSearch.Stone;
                }
                else if (StockpileScript.stone > 0)
                {
                    currentAction = action.Collect;
                    currentSearch = resourceSearch.Stone;
                }
            }
        }
        else if (BuildingToConstruct != null)
        {
            //Debug.Log("Build Construct: Building");
            currentAction = action.Build;
            Objective     = BuildingToConstruct;
        }
        builtSomething = true;
    }
コード例 #3
0
 void Awake()
 {
     m_Instance = this;
 }
コード例 #4
0
ファイル: JimAI.cs プロジェクト: B-Noone/Servare
    void Interact()
    {
        if (currentAction == action.Gather)
        {
            //Debug.Log("Gather");
            if (Objective.name == "StockpileBuilding")
            {
                //Debug.Log("Interact with Building");
                if (inventory == resourceSearch.Food)
                {
                    StockpileScript.food++;
                }
                else if (inventory == resourceSearch.Wood)
                {
                    StockpileScript.wood++;
                }
                else if (inventory == resourceSearch.Stone)
                {
                    StockpileScript.stone++;
                }
                inventory = resourceSearch.Nothing;
            }
            else
            {
                ResourceControl RCScript = Objective.GetComponent <ResourceControl>();
                if (RCScript != null)
                {
                    RCScript.numberOfResource -= 1;
                    if (Objective.name == "Bush")
                    {
                        inventory = resourceSearch.Food;
                    }
                    else if (Objective.name == "Tree")
                    {
                        inventory = resourceSearch.Wood;
                    }
                    else if (Objective.name == "Rock")
                    {
                        inventory = resourceSearch.Stone;
                    }
                }
            }

            ResetVars();
        }
        if (currentAction == action.Collect)
        {
            //Debug.Log("Collect");
            //Stockpile StockScript = Objective.GetComponent<Stockpile>();
            if (currentSearch == resourceSearch.Food && StockpileScript.food != 0)
            {
                StockpileScript.food -= 1;
                inventory             = resourceSearch.Food;
            }
            else if (currentSearch == resourceSearch.Wood && StockpileScript.wood != 0)
            {
                StockpileScript.wood -= 1;
                inventory             = resourceSearch.Wood;
            }
            else if (currentSearch == resourceSearch.Stone && StockpileScript.stone != 0)
            {
                StockpileScript.stone -= 1;
                inventory              = resourceSearch.Stone;
            }
        }
        if (currentAction == action.Build)
        {
            BuildingConstruct BuildScript = Objective.GetComponent <BuildingConstruct>();
            if (inventory == resourceSearch.Wood)
            {
                if (BuildScript.wood > 0)
                {
                    BuildScript.wood    -= 1;
                    inventory            = resourceSearch.Nothing;
                    BuildingToConstruct  = null;
                    BuildingRequirements = null;
                }
            }
            else if (inventory == resourceSearch.Stone)
            {
                if (BuildScript.stone > 0)
                {
                    BuildScript.stone   -= 1;
                    inventory            = resourceSearch.Nothing;
                    BuildingToConstruct  = null;
                    BuildingRequirements = null;
                }
            }
            else
            {
                currentAction = action.Collect;
            }
        }
        //Debug.Log("Reset Vars");
        //ResetVars();
    }