//Function : MovingToDestinationUpdateFunctio //Method : This is the Function that used //For Update Moving To Destination Statement void MovingToDestinationUpdateFunction() { if (Vector3.Distance(transform.position, navMeshAgents.destination) <= navMeshAgents.stoppingDistance) { SetTalkingBooleanStatement(false); resourceCollectiveScript = null; SettingStatement(SCOOPENUMCrtStatement.IDLE); } }
//Function : InstanResourseAreaFunction //Method : This is the Function used For Instan Resourse Area Function public void InstanResourseAreaFunction() { #region InstanGoldObjectRegions InstanResourceAreaScript[] instanResourceAreaScript = FindObjectsOfType <InstanResourceAreaScript>(); BuildObjectScript buildObjectScript = GoldenObj.GetComponent <BuildObjectScript>(); for (int i = 0; i < instanResourceAreaScript.Length; i++) { Transform[] trans = instanResourceAreaScript[i].GetTransformListToArrayFunction(); if (instanResourceAreaScript[i].GetIsInstanGoldArea()) { for (int j = GoldResourceCollectiveScript.Count; j < trans.Length; j++) { GameObject InstanGoldObject = Instantiate(GoldenObj, new Vector3(trans[j].position.x, buildObjectScript.GetYPos(), trans[j].position.z), Quaternion.identity); InstanGoldObject.transform.SetParent(SpawnResourceTransformArea); ResourceCollectiveScript INSTANGOLDOBJAREA = InstanGoldObject.GetComponent <ResourceCollectiveScript>(); GoldResourceCollectiveScript.Add(INSTANGOLDOBJAREA); } } if (instanResourceAreaScript[i].GetisInstanWoodsArea()) { for (int j = 0; j < trans.Length; j++) { GameObject InstanWoodsObj = Instantiate(WoodsObj, new Vector3(trans[j].position.x, buildObjectScript.GetYPos(), trans[j].position.z), instanResourceAreaScript[i].transform.rotation); InstanWoodsObj.transform.SetParent(SpawnResourceTransformArea); ResourceCollectiveScript InstanWoodsArea = InstanWoodsObj.GetComponent <ResourceCollectiveScript>(); WoodsResourceCollectiveScript.Add(InstanWoodsArea); } } } #endregion }
//Function : MovToPositionFunction //Method : This is the Function used For Moving To //The Destination public void MovToPositionFunction(Vector3 pos) { if (energyType.CrtSpirit <= 0) { SettingStatement(SCOOPENUMCrtStatement.IDLE); return; } else if (energyType.CrtSpirit > 0) { anim.SetBool(AnimisTiringBooleanString, false); SettingStatement(SCOOPENUMCrtStatement.MovingToDestination); } StopCoroutine(DOTalkingIEmerator()); StopCoroutine(DODANCEIEnumerator()); isMoving = true; isDoingFighting = false; aiSoilderCtrlScript = null; // navMeshAgents.stoppingDistance = Random.Range(0.2f, 0.9f); navMeshAgents.stoppingDistance = Random.Range(0.8f, 1.45f); SettingStatement(SCOOPENUMCrtStatement.MovingToDestination); anim.SetBool(AnimFarmingBooleanString, false); anim.SetBool(AnimGatheringBooleanString, false); anim.SetBool(AnimisAxeingBooleanString, false); anim.SetBool(AnimisHammeringBooleanString, false); anim.SetBool(AnimisTalkingBooleanString, false); anim.SetBool(AnimMovingBooleanString, true); anim.SetBool(AnimDODanceBoolean, false); anim.SetBool(AnimEQUIPWEAPONBooleanString, false); anim.ResetTrigger(AnimAttackTriggerString); resourceCollectiveScript = null; navMeshAgents.isStopped = false; navMeshAgents.SetDestination(pos); FarmingObject.SetActive(false); if (AxeObject != null) { AxeObject.SetActive(false); } if (WeaponObj != null) { WeaponObj.SetActive(false); } }
//Function : MovToDestinationFarming //Method : This is the Function that used For Moving To The Destination void MovToDestinationFarming() { if (resourceCollectiveScript == null) { SettingStatement(SCOOPENUMCrtStatement.IDLE); return; } anim.SetBool(AnimisTalkingBooleanString, false); anim.SetBool(AnimFarmingBooleanString, false); anim.SetBool(AnimisHammeringBooleanString, false); anim.SetBool(AnimisAxeingBooleanString, false); anim.SetBool(AnimGatheringBooleanString, false); FarmingObject.SetActive(false); if (AxeObject != null) { AxeObject.SetActive(false); } if (HammerObject != null) { HammerObject.SetActive(false); } WeaponObj.SetActive(false); if (Vector3.Distance(transform.position, navMeshAgents.destination) <= navMeshAgents.stoppingDistance) { anim.SetBool(AnimMovingBooleanString, false); SetTalkingBooleanStatement(false); if (resourceCollectiveScript.gameObject != null) { LOOKAT(resourceCollectiveScript.gameObject.transform.position); } else { resourceCollectiveScript = null; SettingStatement(SCOOPENUMCrtStatement.IDLE); } //resourceCollectiveScript = null; SettingStatement(SCOOPENUMCrtStatement.Farming); } }
void MovingToTheResourceDestination(ScoopScript[] SC, Vector3 targetPos, SCOOPENUMCrtStatement PlayerCrtenumStatement , ResourceCollectiveScript rs = null) { Vector3[] Behindpos = ScoopMoverScript.GetUnitGroupDestinationAroundsResources(SC.Length, targetPos); for (int i = 0; i < SC.Length; i++) { if (SC[i].energyType.CrtSpirit > 0) { for (int j = 0; j < Behindpos.Length; j++) { SC[i].MovToResourceFunction(Behindpos[j], PlayerCrtenumStatement, rs); } } } }
//Function : MovToResourceFunction //Method : This is the Function used For Soilder who are going to The Resource Area public void MovToResourceFunction(Vector3 pos, SCOOPENUMCrtStatement scoopEnumType, ResourceCollectiveScript setResourceSource = null) { SettingStatement(scoopEnumType); StopCoroutine(DOTalkingIEmerator()); isMoving = true; aiSoilderCtrlScript = null; anim.SetBool(AnimMovingBooleanString, true); anim.SetBool(AnimFarmingBooleanString, false); anim.SetBool(AnimGatheringBooleanString, false); anim.SetBool(AnimisHammeringBooleanString, false); anim.SetBool(AnimisAxeingBooleanString, false); anim.SetBool(AnimDODanceBoolean, false); anim.SetBool(AnimisTalkingBooleanString, false); anim.SetBool(AnimEQUIPWEAPONBooleanString, false); anim.ResetTrigger(AnimAttackTriggerString); navMeshAgents.isStopped = false; navMeshAgents.stoppingDistance = Random.Range(0.8f, 1.8f); navMeshAgents.SetDestination(pos); FarmingObject.SetActive(false); resourceCollectiveScript = setResourceSource; if (AxeObject != null) { AxeObject.SetActive(false); } HammerObject.SetActive(false); scoopCrtStatementScript.SetIldeSpriteFunction(); }
//Function : FARMINGUpdateStatement //Method : This is the Function that used To Update The Statement void FARMINGUpdateStatement() { if (TakeDamageBoolean) { return; } //Debug.Log("Farming Update Statement"); if (resourceCollectiveScript == null) { SettingStatement(SCOOPENUMCrtStatement.IDLE); return; } if (aiSoilderCtrlScript != null) { SettingStatement(SCOOPENUMCrtStatement.MovToFighting); return; } isFarming = true; if (energyType.CrtSpirit <= 0) { SettingStatement(SCOOPENUMCrtStatement.IDLE); resourceCollectiveScript = null; return; } SetTalkingBooleanStatement(false); if (Time.time > CollectCrtTiming) { switch (resourceCollectiveScript.resourceType) { case ResourceCollectiveScript.ResourceType.Resource_Farmings: if (energyType.farmerCollectTiming != 0) { CollectCrtTiming = Time.time + CollectDelayTiming / energyType.farmerCollectTiming; switch (scoopEnumType) { case ScoopEnumType.Farmer: wasteEnergy = 0.25f; break; case ScoopEnumType.Gathering: wasteEnergy = 0.7f; break; case ScoopEnumType.Axe: wasteEnergy = 1.25f; break; } energyType.CrtSpirit -= wasteEnergy; FarmingObject.SetActive(true); if (AxeObject != null) { AxeObject.SetActive(false); } if (HammerObject != null) { HammerObject.SetActive(false); } if (WeaponObj != null) { WeaponObj.SetActive(false); } resourceCollectiveScript.GatherAmounts((int)energyType.farmerEnergy * 1); GameObject InstanReceivedObjecPrefab = Instantiate(ReceivedObject, resourceCollectiveScript.transform.position, Quaternion.identity); TextMesh textMesh = InstanReceivedObjecPrefab.GetComponent <TextMesh>(); if (textMesh) { textMesh.text = "Foods Received +" + ((int)energyType.farmerEnergy * 1).ToString(); } anim.SetBool(AnimFarmingBooleanString, true); if (UIManager.instance != null) { UIManager.instance.UpdateCrtResourceTypeFunction (PlayerManagerScript.instance.foods, PlayerManagerScript.instance.recoverFruits, PlayerManagerScript.instance.Woods, PlayerManagerScript.instance.Gold); } } else { Debug.LogError("The Collective Divide Should Not Be Zero"); } break; case ResourceCollectiveScript.ResourceType.Resource_Fruits: if (energyType.gatheringCollectTiming != 0) { CollectCrtTiming = Time.time + CollectDelayTiming / energyType.gatheringCollectTiming; switch (scoopEnumType) { case ScoopEnumType.Farmer: wasteEnergy = 0.65f; break; case ScoopEnumType.Gathering: wasteEnergy = 0.15f; break; case ScoopEnumType.Axe: wasteEnergy = 1.25f; break; } energyType.CrtSpirit -= wasteEnergy; FarmingObject.SetActive(false); if (AxeObject != null) { AxeObject.SetActive(false); } if (HammerObject != null) { HammerObject.SetActive(false); } if (WeaponObj != null) { WeaponObj.SetActive(false); } anim.SetBool(AnimGatheringBooleanString, true); if (resourceCollectiveScript.CrtAmount < 0) { resourceCollectiveScript.CrtAmount = 0; SettingStatement(SCOOPENUMCrtStatement.IDLE); } resourceCollectiveScript.GatherAmounts((int)energyType.gatheringEnergy * 1); GameObject InstanReceivedObjecPrefab = Instantiate(ReceivedObject, resourceCollectiveScript.transform.position, Quaternion.identity); TextMesh textMesh = InstanReceivedObjecPrefab.GetComponent <TextMesh>(); if (textMesh) { textMesh.text = "Fruits +" + ((int)energyType.gatheringEnergy * 1).ToString(); } if (UIManager.instance != null) { UIManager.instance.UpdateCrtResourceTypeFunction (PlayerManagerScript.instance.foods, PlayerManagerScript.instance.recoverFruits, PlayerManagerScript.instance.Woods, PlayerManagerScript.instance.Gold); } } else { Debug.LogError("The Collective Divide Should Not Be Zero"); } break; case ResourceCollectiveScript.ResourceType.Resource_Axings_Woods: if (energyType.axeCollectTiming != 0) { switch (scoopEnumType) { case ScoopEnumType.Farmer: wasteEnergy = 1.45f; break; case ScoopEnumType.Gathering: wasteEnergy = 0.95f; break; case ScoopEnumType.Axe: wasteEnergy = 0.65f; break; } FarmingObject.SetActive(false); if (HammerObject != null) { HammerObject.SetActive(false); } if (WeaponObj != null) { WeaponObj.SetActive(false); } if (AxeObject != null) { AxeObject.SetActive(true); } CollectCrtTiming = Time.time + CollectDelayTiming / energyType.axeCollectTiming; energyType.CrtSpirit -= wasteEnergy; anim.SetBool(AnimisAxeingBooleanString, true); resourceCollectiveScript.GatherAmounts((int)energyType.axeEnergy * 1); GameObject InstanReceivedObjecPrefab = Instantiate(ReceivedObject, resourceCollectiveScript.transform.position, Quaternion.identity); TextMesh textMesh = InstanReceivedObjecPrefab.GetComponent <TextMesh>(); if (textMesh) { textMesh.text = "WOODS +" + ((int)energyType.axeEnergy * 1).ToString(); } if (textMesh) { textMesh.text = ""; } if (resourceCollectiveScript.CrtAmount < 0) { resourceCollectiveScript.CrtAmount = 0; SettingStatement(SCOOPENUMCrtStatement.IDLE); } if (UIManager.instance != null) { UIManager.instance.UpdateCrtResourceTypeFunction (PlayerManagerScript.instance.foods, PlayerManagerScript.instance.recoverFruits, PlayerManagerScript.instance.Woods, PlayerManagerScript.instance.Gold); } } else { Debug.LogError("The Collective Divide Should Not Be Zero"); } break; case ResourceCollectiveScript.ResourceType.Resource_Gold: if (energyType.axeCollectTiming != 0) { switch (scoopEnumType) { case ScoopEnumType.Farmer: wasteEnergy = 1.75f; break; case ScoopEnumType.Gathering: wasteEnergy = 2.4f; break; case ScoopEnumType.Axe: wasteEnergy = 1.3f; break; } //if (AxeObject != null) //{ // AxeObject.SetActive(true); //} CollectCrtTiming = Time.time + CollectDelayTiming / energyType.axeCollectTiming; // energyType.CrtSpirit -= wasteEnergy; FarmingObject.SetActive(false); if (HammerObject != null) { HammerObject.SetActive(true); } if (WeaponObj != null) { WeaponObj.SetActive(false); } if (AxeObject != null) { AxeObject.SetActive(false); } anim.SetBool(AnimisHammeringBooleanString, true); resourceCollectiveScript.GatherAmounts((int)energyType.axeEnergy * 1); GameObject InstanReceivedObjecPrefab = Instantiate(ReceivedObject, resourceCollectiveScript.transform.position, Quaternion.identity); TextMesh textMesh = InstanReceivedObjecPrefab.GetComponent <TextMesh>(); if (textMesh) { textMesh.text = "GOLD +" + ((int)energyType.axeEnergy * 1).ToString(); } if (resourceCollectiveScript.CrtAmount < 0) { resourceCollectiveScript.CrtAmount = 0; SettingStatement(SCOOPENUMCrtStatement.IDLE); } if (UIManager.instance != null) { UIManager.instance.UpdateCrtResourceTypeFunction (PlayerManagerScript.instance.foods, PlayerManagerScript.instance.recoverFruits, PlayerManagerScript.instance.Woods, PlayerManagerScript.instance.Gold); } } else { Debug.LogError("The Collective Divide Should Not Be Zero"); } break; } if (scoopCrtStatementScript.GetEmotionBubbleGameObject().gameObject.activeInHierarchy) { scoopCrtStatementScript.SETWorkingSpriteFunction(); } } // StopCoroutine(DOTalkingIEmerator()); }
//Function : SettingStatement //Method : This Function is used For Setting The Function which is Setting The Statement public void SettingStatement(SCOOPENUMCrtStatement toscoop) { scoopEnum = toscoop; if (this.gameObject != null) { if (scoopEnum == SCOOPENUMCrtStatement.IDLE) { isMoving = false; isFarming = false; resourceCollectiveScript = null; navMeshAgents.isStopped = true; anim.SetBool(AnimMovingBooleanString, false); anim.SetBool(AnimFarmingBooleanString, false); anim.SetBool(AnimGatheringBooleanString, false); anim.SetBool(AnimisAxeingBooleanString, false); anim.SetBool(AnimisHammeringBooleanString, false); anim.SetBool(AnimisTalkingBooleanString, false); anim.ResetTrigger(AnimAttackTriggerString); SetTalkingBooleanStatement(false); if (energyType.CrtSpirit <= 0) { anim.SetBool(AnimisTiringBooleanString, true); } else if (energyType.CrtSpirit > 0) { anim.SetBool(AnimisTiringBooleanString, false); } navMeshAgents.ResetPath(); if (FarmingObject != null) { FarmingObject.SetActive(false); } if (AxeObject != null) { AxeObject.SetActive(false); } if (HammerObject != null) { HammerObject.SetActive(false); } if (WeaponObj != null) { WeaponObj.SetActive(false); } isDoingFighting = false; aiSoilderCtrlScript = null; } } }