示例#1
0
 public void Init()
 {
     scene      = new GameScene();
     render     = new RenderFrame();
     controller = new UController();
     scene.SetMatrixProjection(
         Matrix4.CreatePerspectiveFieldOfView(MathHelper.DegreesToRadians(45.0f), Width / Height, 0.1f, 20.0f));
     //scene.SetMatrixProjection(Matrix4.CreateOrthographicOffCenter(-6.0f, 6.0f, -6.0f, 6.0f, 0.1f, 20.0f));
     controller.init(scene.objects);
     controller.run();
 }
示例#2
0
 public void Attach(UController controller)
 {
     if (Controller != null)
     {
         Controller.OnDetach(this);
     }
     _controller = controller;
     if (Controller != null)
     {
         Controller.OnAttach(this);
     }
 }
示例#3
0
        public override void OnEnterState()
        {
            UController controller = _machine._uflow.GetController(_machine);

            if (controller != null)
            {
                MapModel map    = AmbitionApp.GetModel <MapModel>();
                GuestVO  guest  = map.Room.Guests[controller.transform.GetSiblingIndex()];
                string   reward = Util.RNG.TakeRandom(guest.Action.Tags);
                guest.Action.Tags   = new string[] { reward };
                guest.Action.Rounds = guest.Action.Values[reward];
            }
        }
        override public bool Validate()
        {
            MapModel    map        = AmbitionApp.GetModel <MapModel>();
            UController controller = _machine._uflow.GetController(_machine);
            int         index      = controller.transform.GetSiblingIndex();

            if (index >= map.Room.Guests.Length)
            {
                return(false);
            }
            GuestVO guest = map.Room.Guests[index];

            return(guest.Action != null && guest.Action.Type == _actionType);
        }
        public override bool Validate()
        {
            UController controller = _machine._uflow.GetController(_machine);

            if (controller == null)
            {
                return(false);
            }

            MapModel map   = AmbitionApp.GetModel <MapModel>();
            GuestVO  guest = map.Room.Guests[controller.transform.GetSiblingIndex()];

            return(guest.Action != null && guest.Action.Rounds > 0);
        }
示例#6
0
        private void HandleGuest(GuestVO guest)
        {
            UController controller = _machine._uflow.GetController(_machine);

            if (guest != null && controller != null)
            {
                ConversationModel model = AmbitionApp.GetModel <ConversationModel>();
                int index = controller.transform.GetSiblingIndex();
                if (model.Remark != null &&
                    model.Remark.Interest != guest.Dislike &&
                    guest == model.Guests[index])
                {
                    Activate();
                }
            }
        }
        override public void OnEnterState()
        {
            UController controller = _machine._uflow.GetController(_machine);

            if (controller != null)
            {
                MapModel map   = AmbitionApp.GetModel <MapModel>();
                GuestVO  guest = map.Room.Guests[controller.transform.GetSiblingIndex()];
                if (guest.Action != null && guest.Action.Tags != null && guest.Action.Tags.Length > 0)
                {
                    switch (guest.Action.Tags[0])
                    {
                    case "Map":
                        RoomVO[] rooms = Array.FindAll(map.Map.Rooms, r => !r.Revealed);
                        RoomVO   room  = rooms[Util.RNG.Generate(rooms.Length)];
                        room.Revealed = true;
                        AmbitionApp.SendMessage(room);
                        break;

                    case "Wine":
                        AmbitionApp.SendMessage(PartyMessages.REFILL_DRINK);
                        break;

                    case "Remarks":
                        AmbitionApp.SendMessage(PartyMessages.FREE_REMARK);
                        AmbitionApp.SendMessage(PartyMessages.FREE_REMARK);
                        AmbitionApp.SendMessage(PartyMessages.FREE_REMARK);
                        break;

                    case "Accolade":
                        foreach (GuestVO g in map.Room.Guests)
                        {
                            g.Opinion += (g == guest ? 30 : 10);
                            if (g.Opinion >= 100)
                            {
                                g.Opinion   = 100;
                                guest.State = GuestState.Charmed;
                            }
                        }
                        break;
                    }
                }
            }
        }
示例#8
0
        override public void OnEnterState()
        {
            UController controller = _machine._uflow.GetController(_machine);

            if (controller != null)
            {
                ConversationModel model = AmbitionApp.GetModel <ConversationModel>();
                GuestVO           guest = model.Guests[controller.transform.GetSiblingIndex()];
                if (guest.Action != null && guest.Action.Values != null)
                {
                    int reward;
                    int others;
                    guest.Action.Values.TryGetValue("guest", out reward);
                    guest.Action.Values.TryGetValue("others", out others);
                    guest.Opinion += reward - others;
                    Array.ForEach(model.Guests, g => g.Opinion += others);
                }
            }
        }
        override public void OnEnterState()
        {
            MapModel      map        = AmbitionApp.GetModel <MapModel>();
            UController   controller = _machine._uflow.GetController(_machine);
            GuestVO       guest      = map.Room.Guests[controller.transform.GetSiblingIndex()];
            PartyModel    model      = AmbitionApp.GetModel <PartyModel>();
            GuestActionVO action     = AmbitionApp.Create <string, GuestActionVO>("Interest");

            action.Tags = new string[] { guest.Like, "" };
            int index = Util.RNG.Generate(1, model.Interests.Length);

            if (guest.Like == model.Interests[index])
            {
                index = 0;
            }
            guest.Like     = model.Interests[index];
            guest.Dislike  = model.Interests[(index + 1) % model.Interests.Length];
            action.Tags[1] = guest.Like;
            guest.Action   = action;
            AmbitionApp.SendMessage(guest);
        }
示例#10
0
        override public void OnEnterState()
        {
            // Using Sibling Index is hacky as f**k, but this should work for our purposes FRN.
            // VERY dependent on the view.
            MapModel    map        = AmbitionApp.GetModel <MapModel>();
            PartyModel  model      = AmbitionApp.GetModel <PartyModel>();
            UController controller = _machine._uflow.GetController(_machine);
            int         index      = controller.transform.GetSiblingIndex();

            if (index < map.Room.Guests.Length && map.Room.Guests[index] != null)
            {
                int[] chart = map.Room.Guests[index].State == GuestState.Charmed
                    ? model.CharmedGuestActionChance
                    : model.GuestActionChance;
                if (Util.RNG.Generate(chart[map.Room.Difficulty - 1]) > 0)
                {
                    map.Room.Guests[index].Action = null;
                }
                else
                {
                    GuestActionFactory factory = (GuestActionFactory)AmbitionApp.GetFactory <string, GuestActionVO>();
                    GuestActionVO[]    actions = factory.Actions.Values.ToArray();
                    actions = Array.FindAll(actions, a => a.Difficulty <= map.Room.Difficulty);
                    int choice = actions.Select(a => a.Chance).Sum();
                    int i      = 0;
                    for (choice = Util.RNG.Generate(choice); actions[i].Chance <= choice; i++)
                    {
                        choice -= actions[i].Chance;
                    }
                    map.Room.Guests[index].Action = actions[i];
                }
            }
            else
            {
                controller.gameObject.SetActive(false);
            }
        }
示例#11
0
        protected override void OnKeyDown(KeyboardKeyEventArgs e)
        {
            if (e.Key.Equals(Key.Up))//0
            {
                controller.addKey(Key.Up);
            }

            if (e.Key.Equals(Key.Down))//1
            {
                controller.addKey(Key.Down);
            }

            if (e.Key.Equals(Key.Right))//2
            {
                controller.addKey(Key.Right);
            }

            if (e.Key.Equals(Key.Left))//3
            {
                controller.addKey(Key.Left);
            }

            if (e.Key.Equals(Key.Space))//Shoot
            {
                controller.addKey(Key.Space);
            }

            if (e.Key.Equals(Key.W))//0
            {
                controller.addKey(Key.W);
            }

            if (e.Key.Equals(Key.S))//1
            {
                controller.addKey(Key.S);
            }

            if (e.Key.Equals(Key.D))//2
            {
                controller.addKey(Key.D);
            }

            if (e.Key.Equals(Key.A))//3
            {
                controller.addKey(Key.A);
            }

            if (e.Key.Equals(Key.Q))//Shoot
            {
                controller.addKey(Key.Q);
            }

            if (e.Key.Equals(Key.N))
            {
                scene.finish = true;
                controller.dispose();
                scene.nextLevel();
                controller = new UController();
                controller.init(scene.objects);
                controller.run();
                scene.finish = false;
            }

            base.OnKeyDown(e);
        }