void GetComponentFunction() { if (scoopScript == null) { scoopScript = GetComponentInParent <ScoopScript>(); } }
//Function : AttackUpdateStatementFunction //Method : This Function is used For Attack Update Statement void AttackUpdateStatementFunction() { if (scoopScript == null) { stateMachineScript.PushStateFunction(IdleEnterStatementFunction, IdleExitStatementFunction, IdleUpdateStatementFunction); return; } float WithPlayerDistance = Vector3.Distance(this.transform.position, scoopScript.transform.position); if (WithPlayerDistance > 1.0f) { stateMachineScript.PushStateFunction(MovToAttackEnterFunction, MovToAttackExitFunction, MovToAttackUpdateFunction); } else if (WithPlayerDistance <= 1.0f) { // Debug.Log("Attack Player Distance Between 1.0f "); if (!isDead) { if (!HasGetHit) { AttackCrtTimer -= Time.deltaTime; if (AttackCrtTimer <= 0) { if (!scoopScript.isDead) { anim.SetTrigger(AnimDoAttackString); AttackMaxTimer = Random.Range(8.0f, 12.0f); AttackCrtTimer = AttackMaxTimer; } else { scoopScript = null; } } } } else { stateMachineScript.PushStateFunction(DeadEnterStatement, null, null); } } }
//Function : MovToAttackUpdateFunction //Method : Mov To Attack Player Statement Update void MovToAttackUpdateFunction() { if (isDead) { stateMachineScript.PushStateFunction(DeadEnterStatement, null, null); return; } if (scoopScript == null) { stateMachineScript.PushStateFunction(IdleEnterStatementFunction, IdleExitStatementFunction, IdleUpdateStatementFunction); return; } if (navMeshAgent.remainingDistance <= navMeshAgent.stoppingDistance) { // Debug.Log("This is the Function used For Setting The Attack Statement "); stateMachineScript.PushStateFunction(AttackEnterStatementFunction, AttackExitStatementFunction, AttackUpdateStatementFunction); } float distanceWithPlayer = Vector3.Distance(this.transform.position, scoopScript.transform.position); if (distanceWithPlayer > 5.0f) { scoopScript = null; } else if (distanceWithPlayer > 2.5f && distanceWithPlayer <= 5.0f) { stateMachineScript.PushStateFunction(IdleEnterStatementFunction, IdleExitStatementFunction, IdleUpdateStatementFunction); } }
//Function : CreateInstantiateObject //Method : This is the Function used To Create Instantiate Object public void CreateInstantiateObject() { if (scoopScriptList.Count <= 20) { switch (ScoopIndex) { //0 Farmer case 0: if (farmerfoodscost > foods) { return; } break; //1 Fruits Collecter case 1: if (fruitCollecterCost > foods) { return; } break; //2 : Axer case 2: if (AxerCost > foods) { return; } break; case 3: if (HammerCost > foods) { return; } break; } GameObject InstanTroopsObject = Instantiate(ScoopGameObjects[ScoopIndex], TempInstanPosition.position, Quaternion.identity); InstanTroopsObject.transform.SetParent(InstanTroopTransformSettings); ScoopScript scoopScript = InstanTroopsObject.GetComponent <ScoopScript>(); scoopScriptList.Add(scoopScript); switch (ScoopIndex) { //0 Farmer case 0: foods -= farmerfoodscost; farmerInteger++; break; //1 Fruits Collecter case 1: foods -= fruitCollecterCost; fruitCollectorInteger++; break; //2 : Axer case 2: foods -= AxerCost; axerInteger++; break; case 3: foods -= HammerCost; hammerInteger++; break; } } else if (scoopScriptList.Count >= 21) { Debug.Log("You Can't Create More Troop"); } UpdateCurrentTheCostAndCountHavePassedFunction(); UIManager.instance.UpdateCrtResourceTypeFunction(foods, recoverFruits, Woods, Gold);; }
//Function : MouseBtnDownSelectedFunction //Method : This is the Function used To Selected The Function Statement void MouseBtnDownSelectedFunction(Vector2 screenPosition) { Ray ray = cam.ScreenPointToRay(screenPosition); RaycastHit rayCastHit; if (Physics.Raycast(ray, out rayCastHit, Mathf.Infinity, UnitLayerMask)) { scoopListScript.Clear(); ScoopScript scoopscriptWithCollider = rayCastHit.collider.GetComponent <ScoopScript>(); if (PlayerManagerScript.instance.scoopScriptList.Contains(scoopscriptWithCollider)) { if (scoopscriptWithCollider != null) { scoopListScript.Add(scoopscriptWithCollider); scoopscriptWithCollider.GetHasBeenSelectorObject().SetActive(true); // scoopscriptWithCollider.GETSCOOPUICRTSTATEMENT().gameObject.SetActive(true); SETBubbleObjectActiveFunction(true); } } } else if (Physics.Raycast(ray, out rayCastHit, Mathf.Infinity, AreaLevelBlock)) { if (rayCastHit.collider.gameObject.CompareTag(TagsObjectScript.CantCreateBuildingObjTagsName)) { if (!UIManager.instance.HasEnterTheBtnBoolean) { if (!UIManager.instance.GetUNLockPanelObject().activeInHierarchy) { if (!UIManager.instance.GetRequireLevelPanelFunction().activeInHierarchy) { InstanEnemiesScirpt instanEnemiesScript = rayCastHit.collider.GetComponent <InstanEnemiesScirpt>(); SetInstanEnemyFunction(instanEnemiesScript); if (instanEnemiesScript != null) { if (instanEnemiesScript.Unlocked) { if (PlayerManagerScript.instance.Gold >= instanEnemiesScript.GoldenCost) { UIManager.instance.GetYesButtonFunction().interactable = true; UIManager.instance.GetNoButtonFunction().interactable = true; } else if (PlayerManagerScript.instance.Gold < instanEnemiesScript.GoldenCost) { UIManager.instance.GetYesButtonFunction().interactable = false; UIManager.instance.GetNoButtonFunction().interactable = true; } UIManager.instance.GetUNLockPanelObject().SetActive(true); SetCostFunction(instanEnemiesScript.GoldenCost); } else { UIManager.instance.GetUNLockPanelObject().SetActive(false); } // SetAskingCubeObject(rayCastHit.collider.GetComponent<AskingCubeBoxScript>()); } } } if (!UIManager.instance.GetRequireLevelPanelFunction().activeInHierarchy) { SetHaveLevelToUnlockThisGround(rayCastHit.collider.gameObject.GetComponent <HaveLevelToUnlockThisGroundScript>()); // Debug.Log(haveLevelToUnlockThisGroundScript); if (haveLevelToUnlockThisGroundScript != null) { // Debug.Log("Has Pressed The Has Level To Unlock "); // Debug.Log("You Have Click The To Unlock Level"); if (haveLevelToUnlockThisGroundScript.isUnlock) { if (PlayerManagerScript.instance.Gold >= haveLevelToUnlockThisGroundScript.Cost) { UIManager.instance.GetYesButtonFunction().interactable = true; UIManager.instance.GetNoButtonFunction().interactable = true; } else if (PlayerManagerScript.instance.Gold < haveLevelToUnlockThisGroundScript.Cost) { UIManager.instance.GetYesButtonFunction().interactable = false; UIManager.instance.GetNoButtonFunction().interactable = true; } SetCostFunction(haveLevelToUnlockThisGroundScript.Cost); UIManager.instance.GetUNLockPanelObject().SetActive(true); } else { UIManager.instance.GetRequireLevelPanelFunction().SetActive(true); UIManager.instance.SetRequiredLevelTextFunction(haveLevelToUnlockThisGroundScript.GetTheUnlockRequipmentTextFunction()); UIManager.instance.SetHaveUnlockLevelTextFunction(haveLevelToUnlockThisGroundScript.GetTheHaveUnlockRequipmentTextFunction()); } } } } } } }
//Function : DAYPassedBtnFunction //Method : This is the Function that used For Day Passed Btn Function public void DayPassedBtnFunction() { if (GameManager.instance != null) { GameManager.instance.DayInteger++; DayText.text = "DAYS :" + GameManager.instance.DayInteger.ToString(); } GameManager.instance.InstantiateSoilderFunction(); PlayerManagerScript.instance.UpdateCurrentTheCostAndCountHavePassedFunction(); PlayerManagerScript.instance.foods -= (3 * PlayerManagerScript.instance.scoopScriptList.Count); if (PlayerManagerScript.instance.foods <= 3 * PlayerManagerScript.instance.scoopScriptList.Count) { int count = Random.Range(0, PlayerManagerScript.instance.scoopScriptList.Count); ScoopScript containScript = PlayerManagerScript.instance.scoopScriptList[count]; if (PlayerManagerScript.instance.scoopScriptList.Contains(containScript)) { switch (containScript.scoopEnumType) { case ScoopEnumType.Farmer: PlayerManagerScript.instance.GETFARMERINTEGER--; break; case ScoopEnumType.Gathering: PlayerManagerScript.instance.GETFRUITCOLLECTOR--; break; case ScoopEnumType.Axe: PlayerManagerScript.instance.GETAXERInterger--; break; case ScoopEnumType.Hammer: PlayerManagerScript.instance.GETHAMMERINTEGER--; break; } Destroy(containScript.gameObject); PlayerManagerScript.instance.scoopScriptList.Remove(containScript); } } if (PlayerManagerScript.instance.foods <= 0) { PlayerManagerScript.instance.foods = 0; } // CameraCtrl.instance.transform.position= CameraCtrl.instance.GETDefaultPositionFunction().position; for (int i = 0; i < PlayerManagerScript.instance.scoopScriptList.Count; i++) { PlayerManagerScript.instance.scoopScriptList[i].SettingStatement(SCOOPENUMCrtStatement.IDLE); PlayerManagerScript.instance.scoopScriptList[i].GetAnimatorFunction().SetBool (PlayerManagerScript.instance.scoopScriptList[i].GetTiringStringFunction() , false); PlayerManagerScript.instance.scoopScriptList[i].GetAnimatorFunction().SetBool (PlayerManagerScript.instance.scoopScriptList[i].GetisTalkingStringFunction(), false); PlayerManagerScript.instance.scoopScriptList[i].GetAnimatorFunction().SetBool (PlayerManagerScript.instance.scoopScriptList[i].GetEquipWeaponStringFunction(), false); PlayerManagerScript.instance.scoopScriptList[i].SetTalkingBooleanStatement(false); PlayerManagerScript.instance.scoopScriptList[i].movingToTalkingCrtStatement = 0.0f; PlayerManagerScript.instance.scoopScriptList[i].movingToTalkingMaxStatement = 15; PlayerManagerScript.instance.scoopScriptList[i].SetEnemySoilderFunctionToNULLFunction(); UpdateCrtResourceTypeFunction (PlayerManagerScript.instance.foods, PlayerManagerScript.instance.recoverFruits, PlayerManagerScript.instance.Woods, PlayerManagerScript.instance.Gold); if (PlayerManagerScript.instance.recoverFruits > 0) { BuildObjectScript[] buildObjectScript = FindObjectsOfType <BuildObjectScript>(); if (PlayerManagerScript.instance.scoopScriptList[i].energyType.CrtSpirit < PlayerManagerScript.instance.scoopScriptList[i].energyType.MaxSpirit) { PlayerManagerScript.instance.scoopScriptList[i].energyType.CrtSpirit += (PlayerManagerScript.instance.recoverFruits * 0.25f) + 2 ; if (buildObjectScript != null) { for (int j = 0; j < buildObjectScript.Length; j++) { if (buildObjectScript[j].CanHaveEnergyBar) { Debug.Log("has Been Instan Before "); PlayerManagerScript.instance.recoverFruits -= 10 / (int)buildObjectScript[j].buildingEnergyClass.ReduceRestNeededFruits; break; } else { PlayerManagerScript.instance.recoverFruits -= 10; break; } } } if (PlayerManagerScript.instance.recoverFruits <= 0) { PlayerManagerScript.instance.recoverFruits = 0; } } if (PlayerManagerScript.instance.scoopScriptList[i].energyType.CrtSpirit >= PlayerManagerScript.instance.scoopScriptList[i].energyType.MaxSpirit) { PlayerManagerScript.instance.scoopScriptList[i].energyType.CrtSpirit = PlayerManagerScript.instance.scoopScriptList[i].energyType.MaxSpirit; } } else if (PlayerManagerScript.instance.recoverFruits <= 0) { if (PlayerManagerScript.instance.scoopScriptList[i].energyType.CrtSpirit < PlayerManagerScript.instance.scoopScriptList[i].energyType.MaxSpirit) { PlayerManagerScript.instance.scoopScriptList[i].energyType.CrtSpirit += 1 ; } else if (PlayerManagerScript.instance.scoopScriptList[i].energyType.CrtSpirit >= PlayerManagerScript.instance.scoopScriptList[i].energyType.MaxSpirit) { PlayerManagerScript.instance.scoopScriptList[i].energyType.CrtSpirit = PlayerManagerScript.instance.scoopScriptList[i].energyType.MaxSpirit; } } } AskingCubeBoxScript[] askingCubeBoxScript = FindObjectsOfType <AskingCubeBoxScript>(); for (int i = 0; i < askingCubeBoxScript.Length; i++) { Destroy(askingCubeBoxScript[i].gameObject); } InstanEnemiesScirpt[] InstanEnemyScript = FindObjectsOfType <InstanEnemiesScirpt>(); for (int i = 0; i < InstanEnemyScript.Length; i++) { if (InstanEnemyScript[i].Unlocked) { InstanEnemyScript[i].Unlocked = false; } InstanEnemyScript[i].InstanEnemyFunction(); } HaveLevelToUnlockThisGroundScript[] haveLevelToUnLock = FindObjectsOfType <HaveLevelToUnlockThisGroundScript>(); for (int i = 0; i < haveLevelToUnLock.Length; i++) { haveLevelToUnLock[i].UpdateTheUnlockStatementFunction(); } PlayerManagerScript.instance.UpdateCurrentTheCostAndCountHavePassedFunction(); GameManager.instance.InstanResourseAreaFunction(); }
//Function : SetScoopScriptFunction //Method : this is the Function used For Setting The public void SetScoopScriptFunction(ScoopScript scoop = null) { scoopScript = scoop; }
//Function : TalkingUpdateStatement //Method : This is the Function used For void TalkingUpdateStatement() { // Debug.Log("is In The Talking Update Statement "); if (HaveTalkingPLAYERObj == null) { SettingStatement(SCOOPENUMCrtStatement.IDLE); StopCoroutine(DOTalkingIEmerator()); return; } if (HaveTalkingPLAYERObj != null) { ScoopScript sS = HaveTalkingPLAYERObj.GetComponent <ScoopScript>(); if (sS.isFarming) { SettingStatement(SCOOPENUMCrtStatement.IDLE); StopCoroutine(DOTalkingIEmerator()); return; } } if (TakeDamageBoolean) { StopCoroutine(DOTalkingIEmerator()); return; } if (aiSoilderCtrlScript != null) { SettingStatement(SCOOPENUMCrtStatement.Fighting); return; } if (energyType.CrtSpirit <= 0) { SettingStatement(SCOOPENUMCrtStatement.IDLE); return; } if (scoopEnum == SCOOPENUMCrtStatement.Farming) { return; } if (aiSoilderCtrlScript == null) { if (!HasStartTalkingIEmerator) { StartCoroutine(DOTalkingIEmerator()); HasStartTalkingIEmerator = true; } } else if (aiSoilderCtrlScript != null) { SettingStatement(SCOOPENUMCrtStatement.MovToFighting); } }