protected void AddUnitSpawnQueue(ActionData action) { string path = "Prefabs/" + UnitNames[action.actionCode - ActionData.UnitStart] + "ForBattle"; //Debug.Log("load path : " + path); GameObject unit = Resources.Load(path) as GameObject; UnitForBattle unitClass = unit.GetComponent <UnitForBattle>(); unitClass.boardX = 15 - action.boardX; unitClass.boardY = action.boardY; unitClass.player = Player.ENEMY; // @@ check and change position when already exists MonoBehaviour.Instantiate(unit); battleManager.spawnUnitQueue.Add(unitClass); }
public bool SearchInBoard(int x, int y, Player me, ref UnitForBattle target) { if (x < 0 || x > 15 || y < 0 || y > 4) { return(false); } if (liveUnitListInBoard[x, y] && liveUnitListInBoard[x, y].player != me) { target = liveUnitListInBoard[x, y]; return(true); } return(false); }
// It's implement for only special moving //protected override void MoveLogic() //{ // Debug.Log(GetName() + " Move!"); // // simple moving, have to change // RemovePosition(); // int count = 0; // while (count < 2 && battleManager.IsEmptyInBoard((int)player + boardX, boardY)) // { // count++; // boardX = (int)player + boardX; // } // SetPosition(); //} protected override bool AttackLogic() { UnitForBattle target = null; // use player value as attack direction if (battleManager.SearchInBoard((int)player + boardX, boardY, player, ref target)) { Debug.Log(GetName() + " Attack!"); target.TakeDamage(atk); // play attack animation return(true); } return(false); }
public UnitCondition(UnitForBattle _host, int _leftTurn) { host = _host; leftTurn = _leftTurn; }