public bool CheckLineOfSight(GameObject alienShip) { //Debug.Log("checking for sight"); // Determine if there is line of sight to the alien ship Vector3 alienShipDirection = alienShip.transform.position - BarrelPivot.transform.position; bool hitEarth = false; AlienShip alienScript = null; RaycastHit[] hits; hits = Physics.RaycastAll(BarrelPivot.transform.position, alienShipDirection, 100f); foreach (RaycastHit hit in hits) { if (hit.transform.tag == "Earth") { hitEarth = true; } if (hit.transform.tag == "Alien") { alienScript = hit.transform.gameObject.GetComponent <AlienShip>(); } } if (!hitEarth) { currentTarget = alienShip; if (alienScript != null && alienScript.TakeDamage()) { FireAt(alienShip.transform.position); } } return(false); }
/* * If target is alien ship it will attack correct enemy */ public static void attackAlienShip(AlienShip target) { if (target != null) { Tank tank = GameManager.instance.playerList[GameManager.instance.currentPlayerIndex].GetComponent<Tank>(); if(isTargetInRange((int)tank.gridPosition.x, (int)tank.gridPosition.y, (int)target.gridPosition.x,(int)target.gridPosition.y, tank.attackRange)){ tank.actionPoints--; tank.attacking = false; //attack logic //roll to hit bool hit = Random.Range(0.0f, 1.0f) <= tank.attackHitRate; if (hit) { //damage logic //In future damage dealt will take in account for target's defense int amountOfDamage = (int)Mathf.Floor(10 + Random.Range(0, 6)); target.HP -= amountOfDamage; } else { print ("Missed"); isMissed=true; } //GameManager.instance.nextTurn(); //After attacking end turn } else { Debug.Log ("Target is out of range!"); } } }
void OnTriggerEnter(Collider collider) { if (collider.tag == "AlienPrefab") { AlienShip aship = collider.gameObject.GetComponent <AlienShip>(); aship.Die(); } }
public override GameObject GetGameObject(GameObjectPlace objectPlace) { GameObject alienShip = new AlienShip() { Figure = GameSettings.AlienShip, GameObjectPlace = objectPlace, GameObjectType = GameObjectType.AlienShip }; return(alienShip); }
void OnTriggerEnter(Collider other) { AlienShip alienScript = other.gameObject.GetComponent <AlienShip>(); if (alienScript != null) { Debug.Log("Boom"); alienScript.TakeDamage(200); Destroy(gameObject); } }
void OnTriggerEnter(Collider other) { AlienShip alienScript = other.gameObject.GetComponent <AlienShip>(); if (alienScript != null) { Debug.Log("Boom"); alienScript.TakeDamage((int)damage); // TODO: Replace with Object Pooling Destroy(gameObject); } }
public async Task CreateShip() { var alienShip = new AlienShip { ComingFromPlanet = "Vampiris", Name = "Garlic", Crew = new[] { new Alien { Name = "Dracula", IsBloodThirsty = true } } }; var shipForDb = new WrappedAlienShip(alienShip); await _alienRepo.SaveAsync(shipForDb); }
static void Initialize(Engine engine) { int startRow = 2; int startCol = 2; int endCol = WorldCols - 2; int alienStartRow = startRow; for (int i = startCol + 4; i < endCol - 10; i++) { if (i == startCol + 15) { alienStartRow++; } if (i == startCol + 20) { alienStartRow--; } AlienShip alien = new AlienShip(new MatrixPosition(alienStartRow, i), new MatrixPosition(0, 1)); engine.AddObject(alien); } PlayerShip player = new PlayerShip(new MatrixPosition(WorldRows - 2, WorldCols / 2)); engine.AddObject(player); }
public void Start() { Player = FindObjectOfType <Player>(); AlienShip = FindObjectOfType <AlienShip>(); }