public void SetMaterial(PerkTypes type) { var component = gameObject.GetComponent<UVMoveBehaviour>(); if (component == null) { throw new MissingComponentException("UVMoveBehaviour not found"); } switch (type) { case PerkTypes.Health: // Red component.newUvs = new Rect(128, 0, 1, 1); break; case PerkTypes.IncreasedBallSpeed: // yellow component.newUvs = new Rect(0, 0, 1, 1); break; case PerkTypes.TripplePoints: component.newUvs = new Rect(0, -128, 1, 1); break; case PerkTypes.DoublePoints: component.newUvs = new Rect(0,-256, 1, 1); break; case PerkTypes.CreatureSlowdown: component.newUvs = new Rect(128, -256, 1, 1); break; case PerkTypes.LessSymbols: component.newUvs = new Rect(128, -128, 1, 1); break; } }
private PerkBehaviour DisplayPerk(PerkTypes type, Vector3 position) { var perkSpawn = GameObjectRegistry.GetObject("perk_spawn"); var root = GameObjectRegistry.GetObject("entity_root"); var gameObject = ResourceManager.CreateInstance<GameObject>("Perks/env_gift_prefab"); var perk = gameObject.GetComponentInChildren<PerkBehaviour>(); perk.SetMaterial(type); switch (type) { case PerkTypes.Health: { perk.HitEffects.Add(new LifeEffect(1)); break; } case PerkTypes.DoublePoints: { perk.HitEffects.Add(new PointsMultiplierEffect(2)); break; } case PerkTypes.TripplePoints: { perk.HitEffects.Add(new PointsMultiplierEffect(3)); break; } case PerkTypes.IncreasedBallSpeed: { perk.HitEffects.Add(new SnowballSpeedModiferEffect()); break; } case PerkTypes.CreatureSlowdown: { perk.HitEffects.Add(new CreatureSlowdownEffect()); break; } case PerkTypes.LessSymbols: { perk.HitEffects.Add(new LessSymbolsEffect()); break; } default: break; } gameObject.transform.parent = root.transform; gameObject.transform.position = perkSpawn.transform.position; gameObject.transform.rotation = Quaternion.LookRotation(Vector3.up); return perk; }
private string GetPerkResourceByType(PerkTypes type) { var name = string.Empty; switch (type) { case PerkTypes.DoublePoints: name = "Perks/gift_blue"; break; case PerkTypes.TripplePoints: name = "Perks/gift_purple"; break; case PerkTypes.LessSymbols: name = "Perks/gift_black"; break; case PerkTypes.CreatureSlowdown: name = "Perks/gift_yellow"; break; case PerkTypes.IncreasedBallSpeed: name = "Perks/gift_green"; break; case PerkTypes.Health: name = "Perks/gift_red"; break; } if (string.IsNullOrEmpty(name)) { throw new ApplicationException("perk type unknown."); } return name; }
public void SpawnPerk(PerkTypes type) { // outsource into init method var perkSpawn = GameObjectRegistry.GetObject("perk_spawn"); var perkImpact = GameObjectRegistry.GetObject("perk_impact"); var perkRetreat = GameObjectRegistry.GetObject("perk_retreat"); var perk = DisplayPerk(type, perkSpawn.transform.position); perk.GrimReaperAppeared += (sender, e) => VoidTargetable(perk); perk.Speed = 240; var arc = new ArcMovementController(perk, perkImpact, 48); arc.ControllerFinished += (sender, e) => { perk.Speed = 20; perk.transform.localRotation = Quaternion.identity; perk.MoveTo(perkRetreat.transform.position, false); perk.QueueController("impact", new WaterImpactController(Environment.SeaLevel) { Strength = 12, Duration = TimeSpan.FromSeconds(10) }); symbolManager.RegisterTargetable(perk); }; perk.QueueController("move", arc); AdjustSymbolChainRange(perk); entities.Add(perk); }