// this factory produces skills from BasicSpells directory public Skill CreateSkill(Player player) { List <Skill> playerSkills = player.ListOfSkills; Skill known = CheckContent(playerSkills); // check what spells from the BasicSpells category are known by the player already if (known == null) // no BasicSpells known - we will return one of them { FireArrow s1 = new FireArrow(); LightFlash s2 = new LightFlash(); WindGust s3 = new WindGust(); // only include elligible spells List <Skill> tmp = new List <Skill>(); if (s1.MinimumLevel <= player.Level) { tmp.Add(s1); // check level requirements } if (s2.MinimumLevel <= player.Level) { tmp.Add(s2); } if (s3.MinimumLevel <= player.Level) { tmp.Add(s3); } if (tmp.Count == 0) { return(null); } Console.WriteLine(tmp.Count); return(tmp[Index.RNG(0, tmp.Count)]); // use Index.RNG for safe random numbers } else if (known.decoratedSkill == null) // a BasicSpell has been already learned, use decorator to create a combo { FireArrowDecorator s1 = new FireArrowDecorator(known); LightFlashDecorator s2 = new LightFlashDecorator(known); WindGustDecorator s3 = new WindGustDecorator(known); List <Skill> tmp = new List <Skill>(); if (s1.MinimumLevel <= player.Level) { tmp.Add(s1); // check level requirements } if (s2.MinimumLevel <= player.Level) { tmp.Add(s2); } if (s3.MinimumLevel <= player.Level) { tmp.Add(s3); } if (tmp.Count == 0) { return(null); } return(tmp[Index.RNG(0, tmp.Count)]); } else { return(null); // a combo of BasicSpells has been already learned - this factory doesn't offer double combos so we stop here } }
public static void Flash(LightFlash flash, GameObject target) { GameObject new_go = new GameObject("_flash"); new_go.transform.position = target.transform.position; Light l = new_go.AddComponent <Light>(); l.range = flash.radius; l.intensity = 0; Sequence FlashSequence = DOTween.Sequence(); FlashSequence.Append(DOTween.To(() => l.intensity, _l => l.intensity = _l, flash.base_intensity, flash.duration).SetEase(flash.intensity)); FlashSequence.AppendCallback(() => GameObject.Destroy(new_go)); FlashSequence.Play(); // MDebug.Log(FlashSequence.Duration() ); l.color = flash.startColor; l.DOColor(flash.endColor, flash.duration); }
// Start is called before the first frame update void Start() { lightFlash = GetComponent <LightFlash>(); lightSource = GetComponent <Light>(); ogIntensity = lightSource.intensity; }
private void UnArchiveSpecials(World world) { var thinkers = world.Thinkers; var sa = world.SectorAction; // Read in saved thinkers. while (true) { var tclass = (SpecialClass)this.reader.ReadByte(); switch (tclass) { case SpecialClass.EndSpecials: // End of list. return; case SpecialClass.Ceiling: this.PadPointer(); var ceiling = new CeilingMove(world); this.reader.BaseStream.Position += 8; ceiling.ThinkerState = LoadGame.GetThinkerState(this.reader.ReadInt32()); ceiling.Type = (CeilingMoveType)this.reader.ReadInt32(); ceiling.Sector = world.Map.Sectors[this.reader.ReadInt32()]; ceiling.Sector.SpecialData = ceiling; ceiling.BottomHeight = new Fixed(this.reader.ReadInt32()); ceiling.TopHeight = new Fixed(this.reader.ReadInt32()); ceiling.Speed = new Fixed(this.reader.ReadInt32()); ceiling.Crush = this.reader.ReadInt32() != 0; ceiling.Direction = this.reader.ReadInt32(); ceiling.Tag = this.reader.ReadInt32(); ceiling.OldDirection = this.reader.ReadInt32(); thinkers.Add(ceiling); sa.AddActiveCeiling(ceiling); break; case SpecialClass.Door: this.PadPointer(); var door = new VerticalDoor(world); this.reader.BaseStream.Position += 8; door.ThinkerState = LoadGame.GetThinkerState(this.reader.ReadInt32()); door.Type = (VerticalDoorType)this.reader.ReadInt32(); door.Sector = world.Map.Sectors[this.reader.ReadInt32()]; door.Sector.SpecialData = door; door.TopHeight = new Fixed(this.reader.ReadInt32()); door.Speed = new Fixed(this.reader.ReadInt32()); door.Direction = this.reader.ReadInt32(); door.TopWait = this.reader.ReadInt32(); door.TopCountDown = this.reader.ReadInt32(); thinkers.Add(door); break; case SpecialClass.Floor: this.PadPointer(); var floor = new FloorMove(world); this.reader.BaseStream.Position += 8; floor.ThinkerState = LoadGame.GetThinkerState(this.reader.ReadInt32()); floor.Type = (FloorMoveType)this.reader.ReadInt32(); floor.Crush = this.reader.ReadInt32() != 0; floor.Sector = world.Map.Sectors[this.reader.ReadInt32()]; floor.Sector.SpecialData = floor; floor.Direction = this.reader.ReadInt32(); floor.NewSpecial = (SectorSpecial)this.reader.ReadInt32(); floor.Texture = this.reader.ReadInt32(); floor.FloorDestHeight = new Fixed(this.reader.ReadInt32()); floor.Speed = new Fixed(this.reader.ReadInt32()); thinkers.Add(floor); break; case SpecialClass.Plat: this.PadPointer(); var plat = new Platform(world); this.reader.BaseStream.Position += 8; plat.ThinkerState = LoadGame.GetThinkerState(this.reader.ReadInt32()); plat.Sector = world.Map.Sectors[this.reader.ReadInt32()]; plat.Sector.SpecialData = plat; plat.Speed = new Fixed(this.reader.ReadInt32()); plat.Low = new Fixed(this.reader.ReadInt32()); plat.High = new Fixed(this.reader.ReadInt32()); plat.Wait = this.reader.ReadInt32(); plat.Count = this.reader.ReadInt32(); plat.Status = (PlatformState)this.reader.ReadInt32(); plat.OldStatus = (PlatformState)this.reader.ReadInt32(); plat.Crush = this.reader.ReadInt32() != 0; plat.Tag = this.reader.ReadInt32(); plat.Type = (PlatformType)this.reader.ReadInt32(); thinkers.Add(plat); sa.AddActivePlatform(plat); break; case SpecialClass.Flash: this.PadPointer(); var flash = new LightFlash(world); this.reader.BaseStream.Position += 8; flash.ThinkerState = LoadGame.GetThinkerState(this.reader.ReadInt32()); flash.Sector = world.Map.Sectors[this.reader.ReadInt32()]; flash.Count = this.reader.ReadInt32(); flash.MaxLight = this.reader.ReadInt32(); flash.MinLight = this.reader.ReadInt32(); flash.MaxTime = this.reader.ReadInt32(); flash.MinTime = this.reader.ReadInt32(); thinkers.Add(flash); break; case SpecialClass.Strobe: this.PadPointer(); var strobe = new StrobeFlash(world); this.reader.BaseStream.Position += 8; strobe.ThinkerState = LoadGame.GetThinkerState(this.reader.ReadInt32()); strobe.Sector = world.Map.Sectors[this.reader.ReadInt32()]; strobe.Count = this.reader.ReadInt32(); strobe.MinLight = this.reader.ReadInt32(); strobe.MaxLight = this.reader.ReadInt32(); strobe.DarkTime = this.reader.ReadInt32(); strobe.BrightTime = this.reader.ReadInt32(); thinkers.Add(strobe); break; case SpecialClass.Glow: this.PadPointer(); var glow = new GlowingLight(world); this.reader.BaseStream.Position += 8; glow.ThinkerState = LoadGame.GetThinkerState(this.reader.ReadInt32()); glow.Sector = world.Map.Sectors[this.reader.ReadInt32()]; glow.MinLight = this.reader.ReadInt32(); glow.MaxLight = this.reader.ReadInt32(); glow.Direction = this.reader.ReadInt32(); thinkers.Add(glow); break; default: throw new Exception("Unknown special in savegame!"); } } }