protected override void UnitUpdate() { //Search out for the enemy! Tile tile = GetComponentInParent <Tile>(); if (terrified) { if (this.hometile.coord == tile.coord) { terrified = false; } else { MoveUnit(this.hometile.coord - tile.coord); } return; } GridManager grid = this.transform.root.GetComponent <GridManager>(); Cultist cultist = tile.GetComponentInChildren <Cultist>(); if (enemyLocation != tile.coord && (tile is SacrificialChamber || cultist != null)) { //OH SHIT enemyLocation = tile.coord; //Play FOUND sound or whatever return; } Vector2Int moveDir = new Vector2Int(0, 0); if (grid.IsValidTile(enemyLocation)) { if (castleLocation == tile.coord) { //We are at the castle! Knight knight = tile.GetComponentInChildren <Knight>(); if (knight != null) { knight.enemyLocation = enemyLocation; } else { //Uhh? Debug.Log("Inquisitor At castle but no knights!"); } enemyLocation.Set(-1, -1); castleLocation.Set(-1, -1); return; } else { if (!grid.IsValidTile(castleLocation)) { Castle closestCastle = LocateClosestGridEntity <Castle>(); if (closestCastle != default(Castle)) { castleLocation = closestCastle.coord; } } //Move towards the castle! moveDir = castleLocation - tile.coord; } } else { Cultist closestCultist = LocateClosestGridEntity <Cultist>(2); if (closestCultist != default(Cultist)) { moveDir = closestCultist.GetComponentInParent <Tile>().coord - tile.coord; } } if (moveDir.magnitude == 0) { if (curWanderTime > this.wanderTime) { MoveUnit(this.hometile.coord - tile.coord); if (this.hometile.coord == tile.coord) { //Made it home, start wandering again. curWanderTime = 0; } } else { MoveUnitRandom(); curWanderTime++; } } else { MoveUnit(moveDir); } }
protected override void UnitUpdate() { //Do your stuff here //First combat (part of move timer?) Tile tile = GetComponentInParent <Tile>(); if (terrified) { if (this.hometile.coord == tile.coord) { terrified = false; } else { MoveUnit(this.hometile.coord - tile.coord); } return; } GridManager grid = this.transform.root.GetComponent <GridManager>(); Cultist cultist = tile.GetComponentInChildren <Cultist>(); Zombie zombie = tile.GetComponentInChildren <Zombie>(); Victim victim = tile.GetComponentInChildren <Victim>(); if (cultist != null) { Debug.Log("MORTAL COMMBAAAAT C"); //MORTAL COMBAAAAT cultist.LoseHealth(1); LoseHealth(1); } else if (zombie != null) { Debug.Log("MORTAL COMMBAAAAT Z"); //MORTAL COMBAAAAT zombie.LoseHealth(1); LoseHealth(1); } else if (victim != null) { //Free the victims from their oppressors! victim.LoseHealth(1); } else { //No combat or victims to save. //First: Think with your pants. Succubus foundSuccubus = LocateClosestGridEntity <Succubus>(1); if (foundSuccubus != null) { //Hey there cute stuff MoveUnit(foundSuccubus.GetComponentInParent <Tile>().coord - tile.coord); } else if (grid.IsValidTile(enemyLocation)) { //Check if we have an alert if (enemyLocation == tile.coord) { //Set it to null, we got to the point. enemyLocation.Set(-1, -1); } else { MoveUnit(enemyLocation - tile.coord); } } else { Cultist foundCultist = LocateClosestGridEntity <Cultist>(1); if (foundCultist != null) { //WE FOUND A CULTIST, F**K EM UP Debug.Log("FOUND A CULTIST, GET EM"); MoveUnit(foundCultist.GetComponentInParent <Tile>().coord - tile.coord); } else if (!(tile is Castle)) { //We arn't on a castle, and there is nothing else to do. //Go home MoveUnit(this.hometile.coord - tile.coord); } } } }