public GameFieldBall(GameField field) { this.field = field; obj = Assets.TryReuse("field_items/ball", field.transform); Error.Verify(obj != null); obj.transform.position = GetSpawnPos(); mctl = obj.AddComponentOnce <MovementController>(); }
public void OnReuse(GameField field) { this.field = field; obj = Assets.TryReuse("field_items/ball", field.transform); Error.Verify(obj != null); obj.transform.position = GetSpawnPos(); mctl.OnReuse(); mctl.ForceCameraAtPos(field.bottom_left_border); }
void SpawnEnemy() { var enemy = Assets.TryReuse(prefab: "Characters/Zombie", activate: false); enemy.transform.position = new Vector3(-50, -10, 150); //invisible point for pre-spawn enemy.SetActive(true); var unit = enemy.GetComponent<CombatUnit>(); unit.Reset(); unit.OnDie.AddListener(OnEnemyDie); enemies.Add(unit); var ai = enemy.GetComponent<EnemyAI>(); ai.Init(); }
public void Start() { var field_go = Assets.TryReuse("field_items/field"); field = field_go.GetComponent <GameField>(); if (field == null) { field = field_go.AddComponentOnce <GameField>(); field.Init(field_go); } else { field.OnReuse(); } var hud = UI.Open <UIHud>(); hud.Init(); hud.SetField(field); }
public void SpawnPlayer() { var point = Game.self.location.GetChild("PlayerSpawnPoint"); Error.Verify(point != null); cam_go = Assets.TryReuse("Cameras/PlayerCamera"); var player_go = Assets.TryReuse(prefab: "Characters/Player", activate: false); player_go.transform.position = new Vector3(point.transform.position.x, point.transform.position.y, point.transform.position.z); player_go.transform.rotation = new Quaternion(point.transform.rotation.x, point.transform.rotation.y, point.transform.rotation.z, point.transform.rotation.w); var unit = player_go.GetComponent<CombatUnit>(); unit.Reset(); unit.OnDamaged.AddListener(OnPlayerDamaged); player = unit; player_go.SetActive(true); hud = UI.Open<UIHud>(); hud.Init(); }
public static GameFieldBlock Create(GameField field, EnumBlockType type, EnumBlockDirection direction) { var block = new GameFieldBlock(); block.type = type; block.direction = direction; var path = "field_items/blocks/"; if (type == EnumBlockType.barrier) { path += string.Format("barrier_{0}", direction); } else { path += type; } block.obj = Assets.TryReuse(path, parent: field.transform); Error.Verify(block.obj != null); var pos = new Vector2(); var border = direction == EnumBlockDirection.up ? field.upper_left_border : field.bottom_left_border; var blocks = direction == EnumBlockDirection.up ? field.blocks.GetUpperBlocks() : field.blocks.GetBottomBlocks(); GameFieldBlock last_block = null; if (blocks != null && blocks.Count > 0) { last_block = blocks[blocks.Count - 1]; } pos.x = last_block != null ? last_block.obj.transform.position.x + block.obj.transform.localScale.x : border.x; pos.y = border.y; block.obj.transform.position = pos; return(block); }