void LayEgg_ExitState() { if (_eggsToLay.Count > 0) { GameObject newEgg = GameObject.Instantiate(Resources.Load("GameObjects/Egg/Prefab/Egg")) as GameObject; Egg eggComponent = newEgg.GetComponent <Egg>(); if (eggComponent != null) { eggComponent.Init(_eggsToLay[0], _team, _position); GameManager.Instance.Eggs[_eggsToLay[0]] = eggComponent; } _eggsToLay.RemoveAt(0); } }
public Egg layEgg(int eggNo, int playerNo, string team, Color col) { Vector3 spawnPosition; spawnPosition.x = transform.position.x; spawnPosition.z = transform.position.z; spawnPosition.y = transform.position.y; Egg newEgg = Instantiate(eggPrefab, spawnPosition, transform.rotation) as Egg; newEgg.Init(eggNo, playerNo, team, (int)transform.position.x, (int)transform.position.z, col); newEgg.transform.parent = gameObject.transform; return(newEgg); }
private TurnError ActEgg(Ant ant, HexDirection direction) { if (direction == HexDirection.CENTER) { return(TurnError.ILLEGAL); } if (ant.Type != AntType.QUEEN) { return(TurnError.NOT_QUEEN); } Vector2Int eggCoord = CoordConverter.MoveHex(ant.gameCoordinates, direction); TurnError tileError = CheckWalkability(eggCoord); if (tileError != TurnError.NONE) { if (tileError == TurnError.COLLISION_ANT) { terrain[eggCoord.x][eggCoord.y].ant.eventInputs.Add(new EventInputBump(CoordConverter.InvertDirection(direction))); } return(tileError); } if (ant.CheckEnergy(Const.EGG_COST)) { ant.UpdateEnergy(-Const.EGG_COST); } else { return(TurnError.NO_ENERGY); } Vector3 newEggWorldPosition = CoordConverter.PlanToWorld(CoordConverter.HexToPos(eggCoord), eggPrefab.transform.position.y); Egg newEgg = Instantiate(eggPrefab, newEggWorldPosition, eggPrefab.transform.rotation); newEgg.Init(ant.team, eggCoord, ant.team.color); ant.team.eggs.Add(newEgg); terrain[eggCoord.x][eggCoord.y].egg = newEgg; isPermanentModif = true; return(TurnError.NONE); }
// Use this for initialization void Start() { egg.Init(winColliders); textScript.Init(egg); }