void Awake() { var dudeGameObject = GameObject.Find("Dude"); if (dudeGameObject == null) { return; } m_dude = dudeGameObject.GetComponent <Dude2>(); m_dude.OnDied.AddListener(() => { m_playView.ShowGameOver(); }); m_playView = GetComponent <PlayView>(); m_playView.SetPlatformCount(GetPlatformCount()); }
public static void InitializeContent() { #region tutorial step 2 #region arena var map = new Point(2000, 2000); var arena = new ArenaControl(); arena.Layers.Canvas.style.backgroundColor = Color.FromGray(0xc0); arena.SetLocation( Rectangle.Of(0, 0, Native.window.Width, Native.window.Height)); arena.SetCanvasSize(map); arena.Control.AttachToDocument(); arena.DrawTextToInfo(Title, new Point(8, 8), Color.Blue); Native.window.onresize += delegate { arena.SetLocation( Rectangle.Of(0, 0, Native.window.Width, Native.window.Height)); arena.SetCanvasPosition( arena.CurrentCanvasPosition ); }; #endregion #endregion var pending = default(Dude2); #region arsenal var arsenal = new Dictionary <string, DudeAnimationInfo> { { "Soldier", new DudeAnimationInfo { Frames_Stand = Frames.WolfSoldier, Frames_Walk = Frames.WolfSoldier_Walk } }, { "Imp", new DudeAnimationInfo { Frames_Stand = Frames.DoomImp, Frames_Walk = Frames.DoomImp_Walk } } }; #endregion #region tutorial step 3 Func <DudeAnimationInfo, Point, Dude2> CreateActor = (_frames, _coords) => { var actor = new Dude2(); actor.Frames = _frames.Frames_Stand; actor.AnimationInfo.Frames_Stand = _frames.Frames_Stand; actor.AnimationInfo.Frames_Walk = _frames.Frames_Walk; actor.Zoom.DynamicZoomFunc = a => 1; actor.SetSize(48, 72); actor.TeleportTo(_coords.X, _coords.Y); actor.Zoom.StaticZoom = DefaultActiorZoom; actor.Direction = Math.PI * 0.5; actor.Control.AttachTo(arena.Layers.Canvas); //actor.HasShadow = _frames.Frames_Stand.Length > 1; if (_frames.Frames_Stand.Length == 1) { actor.Shadow.style.Opacity = 0.4; } actor.AnimationInfo.WalkAnimationInterval = 1000 / 30; return(actor); }; var actors = new List <Dude2> { }; var selection = from i in actors where i.IsSelected select i; arena.ApplySelection += (rect, ev) => { if (pending != null) { return; } foreach (var v in actors) { v.IsSelected = rect.Contains(v.CurrentLocation.ToInt32()); } }; var Argh = new Argh(); var Affirmative = new Affirmative(); var ghoullaugh = new ghoullaugh(); var sheep = new sheep(); var pig = new pig(); var click = new click().AttachToDocument(); arena.SelectionClick += (p, ev) => { if (pending != null) { return; } foreach (var v in selection) { if (v.AnimationInfo.Frames_Stand[0].Source == MyFrames.ManWithHorns.Frames_Stand[0].Source) { ghoullaugh.play(); ghoullaugh = new ghoullaugh(); } else if (v.AnimationInfo.Frames_Stand[0].Source == MyFrames.ThePig.Frames_Stand[0].Source) { pig.play(); pig = new pig(); } else if (v.AnimationInfo.Frames_Stand[0].Source == MyFrames.TheSheep.Frames_Stand[0].Source) { sheep.play(); sheep = new sheep(); } else if (v.AnimationInfo.Frames_Stand[0].Source == Frames.WolfSoldier[0].Source) { Affirmative.play(); Affirmative = new Affirmative(); } else { Argh.play(); Argh = new Argh(); } v.WalkTo(p.ToDouble()); // move in group formation p.X += 16; p.Y += 16; } }; #endregion #region tutorial step 4 #region CreateDialogAt var CreateDialogAt = new { //Dialog = default(IHTMLDiv), Content = default(IHTMLDiv), Width = default(string) } .ToFunc( (Point pos, string width) => { var f = new Form(); f.Show(); f.SizeTo(200, 200); // https://sites.google.com/a/jsc-solutions.net/work/knowledge-base/15-dualvr/20151115/audio //f.PopupInsteadOfClosing(); f.MoveTo(pos.X, pos.Y); //f.SizeTo( //var dialog = new IHTMLDiv(); //dialog.style.SetLocation(pos.X, pos.Y); //dialog.style.backgroundColor = Color.Gray; //dialog.style.padding = "1px"; //var caption = new IHTMLDiv().AttachTo(dialog); //caption.style.backgroundColor = Color.Blue; //caption.style.width = width; //caption.style.height = "0.5em"; //caption.style.cursor = IStyle.CursorEnum.move; //var drag = new DragHelper(caption); //drag.Position = pos; //drag.Enabled = true; //drag.DragMove += // delegate // { // dialog.style.SetLocation(drag.Position.X, drag.Position.Y); // }; var _content = new IHTMLDiv().AttachTo(f.GetHTMLTargetContainer()); _content.style.textAlign = IStyle.TextAlignEnum.center; _content.style.backgroundColor = Color.White; _content.style.padding = "1px"; //dialog.AttachToDocument(); return(new { //Dialog = dialog, Content = _content, Width = width }); } ); #endregion #region dialog var toolbar = CreateDialogAt(new Point(2, 2), "8em"); var combo = new IHTMLSelect(); var build = new IHTMLButton(); build.style.SetSize(72, 72); build.style.padding = "0px"; var avatar = new IHTMLImage().AttachTo(build); var remove = new IHTMLButton("Remove"); combo.AttachTo(toolbar.Content); new IHTMLBreak().AttachTo(toolbar.Content); build.AttachTo(toolbar.Content); new IHTMLBreak().AttachTo(toolbar.Content); remove.AttachTo(toolbar.Content); new IHTMLBreak().AttachTo(toolbar.Content); #endregion #region GetSelectedArsenal Func <DudeAnimationInfo> GetSelectedArsenal = () => { if (arsenal.ContainsKey(combo[combo.selectedIndex].value)) { return(arsenal[combo[combo.selectedIndex].value]); } return(null); }; #endregion Action Refresh = delegate { var i = GetSelectedArsenal(); if (i != null) { avatar.src = i.Images.Random().src; } }; combo.Add(arsenal.Keys.ToArray()); Refresh(); combo.onchange += delegate { Refresh(); click.play(); click = new click().AttachToDocument(); }; #region pending actor arena.MouseMove += p => { if (pending == null) { return; } pending.TeleportTo(p.X, p.Y); }; arena.Layers.User.oncontextmenu += e => { e.preventDefault(); if (pending != null) { pending.Control.Orphanize(); pending = null; arena.ShowSelectionRectangle = true; return; } actors.ForEach( k => k.IsSelected = false ); }; arena.SelectionClick += (p, ev) => { if (pending == null) { return; } pending.TeleportTo(p.X, p.Y); actors.Add(pending); pending.IsHot = false; var x = GetSelectedArsenal(); pending = CreateActor(x, new Point( Native.window.Width / 2, Native.window.Height / 2 ) ); pending.IsHot = true; click.play(); click = new click().AttachToDocument(); }; build.onclick += delegate { if (pending != null) { pending.Control.Orphanize(); pending = null; return; } var x = GetSelectedArsenal(); pending = CreateActor(x, new Point( Native.window.Width / 2, Native.window.Height / 2 ) ); pending.IsHot = true; arena.ShowSelectionRectangle = false; click.play(); click = new click().AttachToDocument(); }; #endregion remove.onclick += delegate { foreach (var v in selection.ToArray()) { v.Control.Orphanize(); actors.Remove(v); } click.play(); click = new click().AttachToDocument(); }; #endregion if (FilterToImpAndSoldier) { } else { #region step 6 { var n = "NPC"; arsenal.Add(n, MyFrames.NPC3); combo.Add(n); } #endregion { var n = "ManWithHorns"; arsenal.Add(n, MyFrames.ManWithHorns); combo.Add(n); } { var n = "TheSheep"; arsenal.Add(n, MyFrames.TheSheep); combo.Add(n); } { var n = "ThePig"; arsenal.Add(n, MyFrames.ThePig); combo.Add(n); } { var n = "TheCactus"; arsenal.Add(n, MyFrames.TheCactus); combo.Add(n); } } if (BeforeAddingDebris != null) { BeforeAddingDebris(arena.Layers.Canvas); } 3.Times( delegate() { new DebrisImages().Images.ForEach( img => img.AttachTo(arena.Layers.Canvas).style.SetLocation(map.X.Random(), map.Y.Random()) ); } ); 16.Times( delegate() { actors.Add( CreateActor(arsenal.Random().Value, new Point(map.X.Random(), map.Y.Random())) ); } ); }
private static Dude2 CreateDude(DudeAnimationInfo LoadedCharacter) { var r = new Dude2(); r.Frames = LoadedCharacter.Frames_Stand; r.AnimationInfo.Frames_Stand = LoadedCharacter.Frames_Stand; r.AnimationInfo.Frames_Walk = LoadedCharacter.Frames_Walk; r.Zoom.DynamicZoomFunc = a => (a + 400) / (800); r.Zoom.StaticZoom = 1.75; r.SetSize(48, 72); r.TeleportTo(100, 100); r.Control.className = "cursorred"; r.TargetLocationDistanceMultiplier = 1; r.Direction = Math.PI.Random() * 2; return r; }
public static Dude2 TeleportTo(this Dude2 e, Point <double> x) { e.TeleportTo(x.X, x.Y); return(e); }
private void Start() { if (Register.register.completion[0]) { btn1.interactable = false; } if (Register.register.completion[1]) { btn2.interactable = false; } if (Register.register.completion[2]) { btn3.interactable = false; } if (Register.register.completion[3]) { btn4.interactable = false; } if (Register.register.completion[4]) { btn5.interactable = false; } if (Register.register.completion[5]) { btn6.interactable = false; } if (Register.register.completion[6]) { btn7.interactable = false; } HubCanvas.SetActive(false); DayInfoSplash.SetActive(true); switch (CountTrueValues()) { case 0: SundialBase.sprite = day1; DayInfoText.text = "Day 1\n(4 days remaining)"; Dude1.SetActive(true); Dude2.SetActive(false); Dude3.SetActive(false); Dude4.SetActive(false); break; case 1: SundialBase.sprite = day2; DayInfoText.text = "Day 2\n(3 days remaining)"; Dude1.SetActive(false); Dude2.SetActive(true); Dude3.SetActive(false); Dude4.SetActive(false); break; case 2: SundialBase.sprite = day3; DayInfoText.text = "Day 3\n(2 days remaining)"; Dude1.SetActive(false); Dude2.SetActive(false); Dude3.SetActive(true); Dude4.SetActive(false); break; case 3: SundialBase.sprite = day4; Invoke("Sans", Random.Range(10.0f, 60.0f)); DayInfoText.text = "Day 4\n(the last day)"; Dude1.SetActive(false); Dude2.SetActive(false); Dude3.SetActive(true); Dude4.SetActive(false); break; case 4: SundialBase.sprite = day5; DayInfoText.text = "Welcome..."; Dude1.SetActive(false); Dude2.SetActive(false); Dude3.SetActive(false); Dude4.SetActive(true); SundialBase.gameObject.SetActive(false); HubCanvas.SetActive(false); btn1.interactable = false; btn2.interactable = false; btn3.interactable = false; btn4.interactable = false; btn5.interactable = false; btn6.interactable = false; btn7.interactable = false; break; case 5: SundialBase.sprite = day6; DayInfoText.text = "Day 6\n(2 days remaining)"; Dude1.SetActive(false); Dude2.SetActive(false); Dude3.SetActive(true); Dude4.SetActive(false); break; case 6: SundialBase.sprite = day7; DayInfoText.text = "Day 7\n(1 days remaining)"; Dude1.SetActive(false); Dude2.SetActive(false); Dude3.SetActive(true); Dude4.SetActive(false); break; case 7: SundialBase.sprite = day7; DayInfoText.text = "Welcome"; Dude1.SetActive(false); Dude2.SetActive(false); Dude3.SetActive(false); Dude4.SetActive(true); break; default: return; } //if (Dude2.activeInHierarchy) //{ Dude2slot1.sprite = floors[Register.register.floors[0]]; Dude2slot2.sprite = floors[Register.register.floors[1]]; Dude2slot3.sprite = floors[Register.register.floors[2]]; //} //if (Dude3.activeInHierarchy) //{ Dude3slot1.sprite = floors[Register.register.floors[0]]; Dude3slot2.sprite = floors[Register.register.floors[1]]; Dude3slot3.sprite = floors[Register.register.floors[2]]; Dude3slot4.sprite = floors[Register.register.floors[3]]; Dude3slot5.sprite = floors[Register.register.floors[4]]; Dude3slot6.sprite = floors[Register.register.floors[5]]; //} Dude4slot1.sprite = gf; Dude4slot2.sprite = floors[Register.register.floors[0]]; Dude4slot3.sprite = floors[Register.register.floors[1]]; Dude4slot4.sprite = floors[Register.register.floors[2]]; Dude4slot5.sprite = floors[Register.register.floors[3]]; Dude4slot6.sprite = roof; Invoke("HideSplashAndShowHub", 3.0f); timing = Time.timeSinceLevelLoad; }