/// <summary> /// This method should only be used by GridDweller. Use that component to represent something on /// the grid. Never interact with this method directly. Throws an exception if trying to set /// a non-emtpy cell to something non-empty, or if trying to set an empty cell as empty again. /// </summary> public void RemoveDwellerFromCell(CellPosition position, GridDweller dweller) { if (position.side == GridClass.PlayerGrid) { playerSideContents[position.x, position.z].Remove(dweller); } else { enemySideContents[position.x, position.z].Remove(dweller); } }
/// <summary> /// This method should only be used by GridDweller. Use that component to represent something on /// the grid. Never interact with this method directly. Throws an exception if trying to set /// a non-emtpy cell to something non-empty, or if trying to set an empty cell as empty again. /// </summary> public void AddDwellerToCell(CellPosition position, GridDweller dweller) { if (position.side == GridClass.PlayerGrid) { playerSideContents[position.x, position.z].Add(dweller); } else { enemySideContents[position.x, position.z].Add(dweller); } }
public GridDweller[] CellContents(CellPosition position) { GridDweller[] contents = new GridDweller[] { }; if (IsValid(position)) { if (position.side == GridClass.PlayerGrid) { return(playerSideContents[position.x, position.z].ToArray()); } else if (position.side == GridClass.EnemyGrid) { return(enemySideContents[position.x, position.z].ToArray()); } } return(contents); }
void Update() { //Vector3 curPos = transform.position; //dweller.SyncCellPositionToRealPosition(); //transform.Translate(velocity * Time.deltaTime); //curPos += velocity * Time.deltaTime; transform.position += velocity * Time.deltaTime; GridDweller[] contents = dweller.GetGridWorld().CellContents(dweller.GetCurrentCell()); GridDweller player = contents.FirstOrDefault((gd) => gd.type == DwellerType.Player); //if(dweller.GetGridWorld().IsTypeInCell(dweller.GetCurrentCell(), DwellerType.Player)) { if (player != null) { // TODO: Deduct health. //Debug.Log("HIT THE PLAYER! (TODO: DEDUCT HEALTH)"); player.GetComponentInParent <Health>().TakeDamage(DamageType.Damage, damage); Destroy(gameObject); } }
/* * public void SetVelocity(Vector3 newVelocity) { * velocity = newVelocity; * } */ void Start() { dweller = GetComponent <GridDweller>(); //SetVelocity(Vector3.back * 4.0f); //velocity = Vector3.back * 4.0f; }
void Start() { dweller = GetComponent <GridDweller>(); }
void Start() { dweller = GetComponent <GridDweller>(); dweller.StartAt(GetRandomCell()); }
void Start() { dweller = GetComponent <GridDweller>(); ResetMoveTimer(); }