public void ToggleToBombing() { State = BomberState.Bombing; moveTargetPositionPoint = OrbitationWheelOfTargetedObject.FindNearestPoint(transform.position); isLaunchingMeteorsAvaiable = true; LaunchingMeteor(); }
public void ToggleToAerialDestructionState() { isLaunchingMeteorsAvaiable = false; isAvaiableForInteraction = false; State = BomberState.DestructingAerial; TimeingManager.SchoudleDelayedFunctionTrigger(1f, RemoveFromSimulation); }
// Update is called once per frame void Update() { switch (curState) { case BomberState.Patrol: if (Vector3.Distance(transform.position, player.position) <= DistanceToThreaten) { curState = BomberState.Threaten; } else { patrol.Patrolling(); } break; case BomberState.Threaten: if (!isThreatening) { StopCoroutine(Threat()); StartCoroutine(Threat()); } break; case BomberState.Attack: if (!isAttacking) { StopCoroutine(Attack()); StartCoroutine(Attack()); } break; } }
// Use this for initialization void Start() { canDrop = true; movement = new MovementData(3); { delay = gameObject.AddComponent <TimerRoutine>(); delay.initTimer(6f); delay.executedFunction = resetBomb; } bombRange = 1; sightRange = bombRange + 4; BoxCollider2D col = gameObject.AddComponent <BoxCollider2D>(); col.size = new Vector2(1f * sightRange, 1f); col.isTrigger = true; col = gameObject.AddComponent <BoxCollider2D>(); col.size = new Vector2(1f, 1f * sightRange); col.isTrigger = true; dmgBody = transform.parent.GetChild(2).gameObject; dmgBody.GetComponent <DefaultCharacter>().InitChar(); e_state = BomberState.E_NEUTRAL; bombRef = null; prevCellPos = GameModeManager.instance.gameGrid.GetWorldFlToCellPos(transform.position); physBody = transform.parent.GetComponent <Rigidbody2D>(); anim = transform.parent.GetChild(3).GetChild(0).GetComponent <Animator>(); guide = transform.parent.GetComponent <BomberGuide>(); colcount = 0; once = false; }
IEnumerator Attack() { isAttacking = true; float timeTaken = 0; foreach (ParticleSystem ps in OozeParticles) { ps.Play(); } attackArea.ActivateAttack(oozeAttack); while (timeTaken < TimeToAttack && curState != BomberState.Die) { timeTaken += Time.deltaTime; transform.position += transform.forward * AttackSpeed * Time.deltaTime; yield return(null); } attackArea.EndAttack(); isAttacking = false; curState = curState == BomberState.Die ? BomberState.Die : BomberState.Patrol; yield return(null); }
public void ToggleToDestructingTargetState(Vector3 _targetPosition) { isLaunchingMeteorsAvaiable = false; State = BomberState.DestructingTarget; //Calculate Vector of Animation Direction // Send Vector To Aniamtionhandler TimeingManager.SchoudleDelayedFunctionTrigger(1f, RemoveFromSimulation); }
public void StartMarching() { marching = true; navMeshAgent.isStopped = false; navMeshAgent.destination = destination.transform.position; navMeshAgent.SetAreaCost(randomArea, 1f); state = BomberState.Marching; UpdateAnimatorWalkSpeed(); }
public override void Setup() { objectRadius = 1.5f; CanBehHitWithImploder = true; healthPoints = 500; State = new BomberState(); OrbitatingSpawnKickTargetPoint = ObjectSpawner.SpawnOrbitatingSpawnKickTargetPoint(this.transform.position); OrbitatingSpawnKickTargetPoint.transform.SetParent(this.transform); }
// Use this for initialization void Start() { patrol = GetComponent <Patrol>(); curState = BomberState.Patrol; OozeParticles = Ooze.GetComponentsInChildren <ParticleSystem>(); player = GameObject.FindWithTag("Player").GetComponent <Transform>(); }
public void Kill() { StopCoroutine(Attack()); StopCoroutine(Threat()); attackArea.EndAttack(); anim.SetBool("Death", true); curState = BomberState.Die; GetComponent <Rigidbody>().useGravity = true; GetComponent <Rigidbody>().isKinematic = false; player.gameObject.GetComponent <SC_CharacterController>().ScoreUp(100); Destroy(gameObject, 2); }
IEnumerator Threat() { isThreatening = true; float timeTaken = 0; while (timeTaken < TimeToThreaten && curState != BomberState.Die) { timeTaken += Time.deltaTime; Vector3 toLookAt = player.position - transform.position; toLookAt.y = 0; Quaternion lr = Quaternion.LookRotation(toLookAt); transform.rotation = Quaternion.RotateTowards(transform.rotation, lr, patrol.RotateSpeed * Time.deltaTime); transform.position += Vector3.up * Mathf.Lerp(0, (player.position.y + 3.5f) - transform.position.y, Time.deltaTime); yield return(null); } isThreatening = false; curState = curState == BomberState.Die ? BomberState.Die : BomberState.Attack; yield return(null); }
public void StartShooting() { state = BomberState.Shooting; animator.SetTrigger("Shoot"); }
public void ToggleToMoveTowardsPlayer() { State = BomberState.MovingTowardsPlayer; isLaunchingMeteorsAvaiable = false; }
void OnTriggerStay2D(Collider2D obj) { // if its not me /*if (obj.gameObject.layer == 14) * { * // get player cell pos * Vector3Int otherBomber = GameModeManager.instance.gameGrid.GetWorldFlToCellPos(obj.transform.position); * //if (detectPlayerApprox(otherBomber, sightRange)) // check if this object is within my sight * if (xyAxisCheck(otherBomber)) // is this object on either of my 4 direction * { * //if (TileRefManager.instance.GetTileAtCellPos(TileRefManager.TILEMAP_TYPE.TILEMAP_SOLIDWALL, findPlayerDir()) == null) * if (XYObstacleCheck(otherBomber, bombRange) == false) // if there is nothing blocking my path to bomb the object * if (canDrop) // if i can drop a bomb right now * { * // Before i drop, i should do some thinking first, is there a cell i can hide? should i drop it in a deliberate place? * dropBomb(); // drop bomb * delay.executeFunction(); // cool down for bomb drop * canDrop = false; * } * //guide.GetComponent<BomberGuide>().setDirection(findNextDirection(otherBomber)); // chase a player or destructable * } * }*/ if (!obj.gameObject.Equals(transform.parent.gameObject) && !obj.gameObject.Equals(dmgBody)) { if (obj.gameObject.layer == 14 && e_state == BomberState.E_NEUTRAL) // is this a object i care about { if (canDrop /* && dmgBody.GetComponent<Inventory>().OnHandAmount > 0*/) // if i can drop a bomb right now { // Before i drop, i should do some thinking first, is there a cell i can hide? should i drop it in a deliberate place? if (XYValidDrop(bombRange)) { List <int> cells = findHidingPlace(GameModeManager.instance.gameGrid.GetWorldFlToCellPos(transform.position), bombRange); guide.findWaypoint(cells, transform.position); if (guide.hasWaypoint) { dropBomb(); // drop bomb } delay.executeFunction(); // cool down for bomb drop canDrop = false; //dmgBody.GetComponent<Inventory>().OnHandAmount--; } } } //else if (e_state == BomberState.E_ALERT && bombRef == null && guide.safetyTimer.hasRun == false) // e_state = BomberState.E_NEUTRAL; if (obj.gameObject.layer == 17 && e_state == BomberState.E_NEUTRAL) { if (canDrop) // if i can drop a bomb right now { // Before i drop, i should do some thinking first, is there a cell i can hide? should i drop it in a deliberate place? if (XYValidDrop(bombRange)) { List <int> cells = findHidingPlace(GameModeManager.instance.gameGrid.GetWorldFlToCellPos(transform.position), bombRange); guide.findWaypoint(cells, transform.position); if (guide.hasWaypoint) { dropBomb(); // drop bomb } delay.executeFunction(); // cool down for bomb drop canDrop = false; } } } // the following block should not be called if it is the bomber's own bomb if (obj.gameObject.layer == 10 && !obj.gameObject.Equals(bombRef) && obj.gameObject.CompareTag("Interactable") && colcount < 2) // is this a solidobject? Ignore my own bomb and do not detect flames which are also solidobjs { int bombRange = obj.gameObject.GetComponent <Bomb>().effectRange; bombRef = obj.gameObject; List <int> cells = findHidingPlace(GameModeManager.instance.gameGrid.GetWorldFlToCellPos(obj.transform.position), obj.gameObject.GetComponent <Bomb>().effectRange); guide.resetWaypoints(); guide.findWaypoint(cells, obj.transform.position); e_state = BomberState.E_AVOID; } else if (e_state == BomberState.E_AVOID && bombRef == null && guide.reachedHiding && guide.safetyTimer.hasRun == false) { e_state = BomberState.E_NEUTRAL; } } }