public void SetTile(LogicElement.LogicElementType t, bool top = false, SnakeSkin skin = null) { Image img = image; if (top) { img = frontImage; } _content = t; ZRotation = 0; switch (t) { case LogicElement.LogicElementType.MyBody: if (skin == null) { img.sprite = _baseSprite; break; } img.sprite = skin.Body; break; case LogicElement.LogicElementType.MyHead: if (skin == null) { img.sprite = _baseSprite; break; } img.sprite = skin.Head; break; case LogicElement.LogicElementType.MyTail: if (skin == null) { img.sprite = _baseSprite; break; } img.sprite = skin.Tail; break; case LogicElement.LogicElementType.MyAngle: if (skin == null) { img.sprite = _baseSprite; break; } img.sprite = skin.Angle; break; case LogicElement.LogicElementType.None: img.sprite = _baseSprite; if (top) { // img.color = new Color(1,1,1,0); } break; } }
public void Init(SnakeSkin ss) { _shopObject = ss; ItemName.text = ss.SkinName; ItemCost.text = ss.SkinCost + ""; ItemPreview.sprite = ss.Head; ByeButton.interactable = Player.Instance.Money >= ss.SkinCost; InfoButton.onClick.AddListener(ShowInfo); ByeButton.onClick.AddListener(Buy); }
public void ChooseSkin(SnakeSkin skin) { if (CurrentSnake == null) { return; } if (!CurrentSnake.Skin.Base) { Player.Instance.AddSkin(CurrentSnake.Skin); } CurrentSnake.Skin = skin; if (!skin.Base) { Player.Instance.RemoveSkin(skin); } SnakeUpdated(); }
public void Buy(object shopObject) { switch (shopObject.GetType().ToString()) { case "ModuleHolder": ModuleHolder moduleHolder = (ModuleHolder)shopObject; Player.Instance.Money -= moduleHolder.Cost; if (moduleHolder.moduleType == ModuleHolder.ModuleType.Simple) { Player.Instance.Modules.Add(new SimpleModule(moduleHolder)); } else { Player.Instance.Modules.Add(new ComplexModule(moduleHolder)); } break; case "SnakeSkin": SnakeSkin snakeSkin = (SnakeSkin)shopObject; Player.Instance.Money -= snakeSkin.SkinCost; Player.Instance.AddSkin(snakeSkin); break; case "LogicElement": LogicElement logicElement = (LogicElement)shopObject; Player.Instance.Money -= logicElement.ElementCost; Player.Instance.AddElements(logicElement, 1); break; case "ShopBonus": ShopBonus bonus = (ShopBonus)shopObject; Player.Instance.Money -= bonus.BonusCost; Player.Instance.AddBonus(bonus); break; } }
public void RemoveSkin(SnakeSkin ss) { PlayerData._skinsIds.Remove(ss.SkinName); OnSkinListChanged(); }
public void AddSkin(SnakeSkin ss) { PlayerData._skinsIds.Add(ss.SkinName); }
private void OnEnable() { _skin = (SnakeSkin)target; }
public void Init(SnakeSkin lm) { _skin = lm; SkinImg.sprite = lm.Head; GetComponent <Button>().onClick.AddListener(ChooseSkin); }
private void CreateSkin(int count) { this.PlaySkin(); while (count > 0) { KeyValuePair<SnakeBody, CellPoint> body = this.snakeBodyList.Last(); CellPoint skinPoint = body.Value; SnakeSkin skin = new SnakeSkin(); skin.SetValue(Canvas.LeftProperty, (double)skinPoint.X * this.cellSize); skin.SetValue(Canvas.TopProperty, (double)skinPoint.Y * this.cellSize); this.skinList.Add(skin, skinPoint); this.canvasSkin.Children.Add(skin); this.emptyCells.Remove(skinPoint); canvasSnake.Children.Remove(body.Key); this.snakeBodyList.Remove(body.Key); count--; } }