public void SpawnApple(AppleState state) { var apple = GetAppleAtPosition(state.position); if (apple) { apple.gameObject.SetActive(true); } else { var newApple = Instantiate(applePrefab, state.position, Quaternion.identity, transform); newApple.SetActive(state.isActive); } }
protected override void RequestDraw() { MainState _currentState = _state; if (_currentState != null) { Index2 cells = _currentState.Map.GetCellCount(); DrawPlayground(cells, _currentState.Map.Tiles); foreach (var item in _currentState.Items) { if (item is AnthillState) { AnthillState anthillState = item as AnthillState; DrawItem(item.Id, item.Position, anthillState.Radius, null, null, Color.Brown, null, null, null, null, null, null); } if (item is AntState) { AntState antState = item as AntState; // DrawItem(item.Id, item.Position, antState.Radius, Color.Black); } if (item is SugarState) { SugarState sugarState = item as SugarState; // DrawItem(item.Id, item.Position, sugarState.Radius, Color.White); } if (item is AppleState) { AppleState appleState = item as AppleState; // DrawItem(item.Id, item.Position, 5, Color.LightGreen); } if (item is MarkerState) { MarkerState markerState = item as MarkerState; // DrawItem(item.Id, item.Position, 10, Color.Yellow); } if (item is BugState) { // DrawItem(item.Id, item.Position, 10, Color.Blue); } } } }
private void InitObjectState() { keyState = KeyState.InRiver; appleState = AppleState.OnTheTree; blackRoseState = BlackRoseState.InVase; cardState = CardState.OnTable; tissueState = TissueState.OnTable; tableSheetState = TableSheetState.OnTable; micPosition = new Vector2(6.56f, -1f); scissorsPosition = new Vector2(-5.43f, -2.1f); threadPosition = new Vector2(10.86f, 3.095f); needlePosition = new Vector2(9.305f, -1.414999f); globePosition = new Vector2(8.65f, 0.535f); earBudState = EarBudState.InShelf; basketState = BasketState.InHand; diaryState = DiaryState.InShelf; violinCaseState = ViolinCaseState.Locked; currentPasswordViolinCase = "DAFUQ"; ViolinState = ViolinState.Enclosed; if (_inBagItems == null) { _inBagItems = new List <string>(); } }