// Update is called once per frame void Update() { if (active) { elapsedTime += Time.deltaTime; if (elapsedTime > spawnDelay && rsc.enemyMng.bb.activeEnemies < maxEnemiesInScene && !zoneWavesFinished) { elapsedTime = 0f; SpiderAIBehaviour enemy = coloredObjMng.GetSpider(ChromaColorInfo.Random, spawnPoint.position); if (enemy != null) { enemy.AIInit(SpiderAIBehaviour.SpawnAnimation.VORTEX, entryActions, attackActions, infectActions); enemy.Spawn(spawnPoint); rsc.enemyMng.AddVortexEnemyInfection(SpiderAIBehaviour.infectionValue); } spawnDelay = Random.Range(spawnMinDelay, spawnMaxDelay); } if (translateVert) { translateElapsedTime += Time.deltaTime; float factor = Mathf.Sin(translateElapsedTime / translateVertFullCycleTime * Mathf.PI * 2); float newRtVertPos = transVertOriginalY + (transVertHalfDisplacement * factor); modelAndFx.position = new Vector3(modelAndFx.position.x, newRtVertPos, modelAndFx.position.z); } } }
public SpiderAIBehaviour GetSpider(ChromaColor color, Vector3 position) { //Get a spider from pool SpiderAIBehaviour spider = spiderPool.GetObject(position); if (spider != null) { spider.color = color; spider.SetMaterials(new[] { GetMaterial(spiderMats, color) }); return(spider); } return(null); }
private SpiderAIBehaviour spider; // TOREFACTOR - this action must be used for any enemy public override void SetAction(AIAction act) { base.SetAction(act); moveAction = (MoveAIAction)act; string tId = moveAction.targetId; spider = (SpiderAIBehaviour)state.parent; // TOREFACTOR - this action must be used for any enemy if (tId != "player") { state.target = GameObject.Find(tId); } else if(!state.target.activeSelf) { state.target = rsc.enemyMng.SelectTarget(); } switch(moveAction.offsetType) { case AIAction.OffsetType.POSITION_ZERO: direction = new Vector3(0, 0, 0); break; case AIAction.OffsetType.AROUND_WORLD_RELATIVE: direction = new Vector3(0, 0, 1); direction = Quaternion.Euler(0, moveAction.angle, 0) * direction; direction *= moveAction.distance; break; case AIAction.OffsetType.AROUND_ENEMY_RELATIVE: direction = (state.agent.transform.position - state.target.transform.position).normalized; direction = Quaternion.Euler(0, moveAction.angle, 0) * direction; direction *= moveAction.distance; break; } if (moveAction.inertia) state.agent.acceleration = 50; else state.agent.acceleration = 1000; state.agent.speed = moveAction.speed; spider.GetComponent<Animator>().speed = moveAction.speed / 4; state.agent.destination = state.target.transform.position + direction; state.agent.Resume(); elapsedTime = 0f; }
public override void InitialSetup(GameObject e) { base.InitialSetup(e); spider = entityGO.GetComponent <SpiderAIBehaviour>(); boltSpawnPoint = entityGO.transform.Find("BoltSpawnPoint"); spawningState = new SpiderSpawningAIState(this); entryState = new SpiderEntryAIState(this); attackingPlayerState = new SpiderAttackingPlayerAIState(this); leadingGroupState = new SpiderLeadingGroupAIState(this); followingGroupState = new SpiderFollowingGroupAIState(this); infectingDeviceState = new SpiderInfectingDeviceAIState(this); attractedToBarrelState = new SpiderAttractedToBarrelAIState(this); dyingState = new SpiderDyingAIState(this); ResetValues(); }
//Spider methods public SpiderAIBehaviour GetSpider(bool random, Vector3 position) { if (random) { return(GetSpider(ChromaColorInfo.Random, position)); } //Get a spider from pool SpiderAIBehaviour spider = spiderPool.GetObject(position); if (spider != null) { spider.color = currentColor; spider.SetMaterials(new[] { currentSpiderMat }); return(spider); } return(null); }
public override void SetAction(AIAction act) { base.SetAction(act); spiderBiteAction = (SpiderBiteAIAction)act; spider = (SpiderAIBehaviour)state.parent; state.agent.Stop(); if(spider.timeSinceLastAttack > spiderBiteAction.minimumTimeSinceLastAttack) { spider.GetComponent<Animator>().SetTrigger("bite"); spider.timeSinceLastAttack = 0f; spider.biting = true; discardedAttack = false; } else { discardedAttack = true; } }
public override HexagonBaseState Update() { ReturnToPlace(); if (hex.AuxTimer < initialTimer) { if (!spawnChecked) { if (rsc.enemyMng.bb.worm != null && rsc.enemyMng.bb.worm.head.CanSpawnMinion()) { SpiderAIBehaviour enemy = rsc.coloredObjectsMng.GetSpider(rsc.colorMng.GetRandomActiveColor(), hex.spawnPoint.transform.position); if (enemy != null) { enemy.AIInit(SpiderAIBehaviour.SpawnAnimation.FLOOR_FAST, hex.entryActions, hex.attackActions, hex.infectActions); enemy.Spawn(hex.spawnPoint.transform); rsc.enemyMng.AddVortexEnemyInfection(SpiderAIBehaviour.infectionValue); } } spawnChecked = true; } } if (hex.AuxTimer < hex.AuxHalfTimer) { hex.plane.transform.localScale = Vector3.Lerp(Vector3.one, half, (hex.AuxHalfTimer - hex.AuxTimer) / hex.AuxHalfTimer); } if (hex.AuxTimer <= 0f) { return(hex.idleState); } return(null); }
// Use this for initialization void Start () { spider = GetComponentInParent<SpiderAIBehaviour>(); }