void Start() { levelingSystem = new LevelingSystem(); battleSystem = new BattleSystem(this, battleCanvas); actionSystem = new ActionSystem(this); Player aragorn = new Aragorn(); Player kvothe = new Kvothe(); Player netero = new Netero(); Player tyrande = new Tyrande(); aragorn.addExperience(200000f); kvothe.addExperience(200000f); netero.addExperience(200000f); tyrande.addExperience(200000f); aragorn.sprite = aragornSprite; kvothe.sprite = kvotheSprite; netero.sprite = neteroSprite; tyrande.sprite = tyrandeSprite; teamPlayer = new List <Entity> { aragorn, kvothe, netero, tyrande }; strategies = new List <BattleStrategy> { new EasyStrategy(), new NormalStrategy() }; soundSystem = gameObject.GetComponent <SoundSystem> (); soundSystem.playAmbientSound(); }
public Entity(string name) { entityName = name; stats = new Stats(this); gameSystem = GameObject.FindObjectOfType <GameSystem> (); actionSystem = gameSystem.getActionSystem(); }
public void Execute(ActionSystem system) { foreach (var behavior in behaviors) { behavior.Execute(system, this); } }
public override void Update(float dt) { base.Update(dt); foreach (var id in this.EntityManager.EntitiesWithComponent(typeof(MenuComponent))) { var menu = this.EntityManager.GetComponent <MenuComponent>(id); if (menu.EntityID_Item <= 0) { SetMenuActive(menu, false); } else { if (ActionSystem.IsBusy(id)) { SetBusyDots(menu, dt); } SetMenuOptions(menu); SetMenuOptionSpacing(menu); SetMenuPosition(id, menu); SetMenuActive(menu, true); } } }
public override void Execute(ActionSystem system, ActionConfig config) { var targetingSystem = system.GetComponent <TargetingSystem>(); Debug.LogFormat("{0} {1} AttackActionBehavior", system.name, config.actionName); Debug.LogFormat("\t Target: {0}", targetingSystem.TargetWorldPosition()); }
public Engine() { kbHandler = new KeyboardHandler(); //gpHandler = new PS4GamePadHandler(0); //TODO: Add support for PS4 controller reqHandler = new RequestHandler(); RenderState.activeGamepad = gpHandler; //Assign new palette to GLControl palette = Palettes.createPalettefromBasePalettes(); renderMgr = new renderManager(); //Init renderManager of the engine //Input Polling Timer inputPollTimer = new System.Timers.Timer(); inputPollTimer.Elapsed += new ElapsedEventHandler(input_poller); inputPollTimer.Interval = 1; //Camera Movement Timer cameraMovementTimer = new System.Timers.Timer(); cameraMovementTimer.Elapsed += new ElapsedEventHandler(camera_timer); cameraMovementTimer.Interval = 20; //cameraMovementTimer.Start(); Start in the main function //Systems Init actionSys = new ActionSystem(); animationSys = new AnimationSystem(); actionSys.SetEngine(this); animationSys.SetEngine(this); }
public Websockethandler(IApplicationBuilder app, ActionSystem actionSystem) { _actionSystem = actionSystem; _actionSockets = new ConcurrentDictionary <int, WebSocket>(); _eventSockets = new ConcurrentDictionary <int, WebSocket>(); SetupWsActionsListener(app); }
public void TestSetup() { NotificationCenter.instance.Clean(); game = new Container(); actionSystem = game.AddAspect <ActionSystem> (); testSystem = game.AddAspect <TestSystem> (); testSystem.Setup(); }
public void TestSetup() { game = new Container(); actionSystem = game.AddAspect <ActionSystem> (); dataSystem = game.AddAspect <DataSystem> (); matchSystem = game.AddAspect <MatchSystem> (); testSkipSystem = game.AddAspect <TestSkipSystem> (); game.Awake(); }
public void RemoveViewer <T>(ActionViewer viewer) where T : GameAction { var typeName = ActionSystem.GetActionType <T>(); if (actionViewerMap.ContainsKey(typeName)) { actionViewerMap[typeName].Remove(viewer); } }
// 单例的使用 private ControllerCenter() { renderSystem = new RendererSystem(); playerSystem = new PlayerSystem(); ActionSystem = new ActionSystem(); gameobjectSystem = new GameObjectSystem(); itemSystem = new ItemSystem(); skillitemSystem = new SkillItemSystem(); }
public void RemoveListener <T>(UnityAction <GameAction> listener) where T : GameAction { var typeName = ActionSystem.GetActionType <T>(); if (listeners.ContainsKey(typeName)) { listeners[typeName].RemoveListener(listener); } }
public void InvokePerformEvent <T>(T action) where T : GameAction { var typeName = ActionSystem.GetActionType(action); if (listeners.ContainsKey(typeName)) { var performEvent = listeners[typeName]; performEvent.Invoke(action); } }
public void Update_Should_call_the_action() { bool done = false; ISystem <int> system = new ActionSystem <int>(_ => done = true); system.Update(0); Check.That(done).IsTrue(); }
public void AddListener <T>(UnityAction <GameAction> listener) where T : GameAction { var typeName = ActionSystem.GetActionType <T>(); if (!listeners.ContainsKey(typeName)) { listeners.Add(typeName, new ActionEvent()); } listeners[typeName].AddListener(listener); }
public void AddViewer <T>(ActionViewer viewer) where T : GameAction { var typeName = ActionSystem.GetActionType <T>(); if (!actionViewerMap.ContainsKey(typeName)) { actionViewerMap.Add(typeName, new List <ActionViewer>(1)); } actionViewerMap[typeName].Add(viewer); }
public void Update_Should_not_call_the_action_When_disabled() { bool done = false; ISystem <int> system = new ActionSystem <int>(_ => done = true) { IsEnabled = false }; system.Update(0); Check.That(done).IsFalse(); }
public List <ActionViewer> GetViewers <T>(T action) where T : GameAction { var typeName = ActionSystem.GetActionType(action); if (actionViewerMap.ContainsKey(typeName)) { return(actionViewerMap[typeName]); } else { Debug.LogWarning(string.Format("No viewers present for {0}. Returning null.", typeName)); return(null); } }
private void WireActions(IEnumerable <IModule> modules) { ActionSystem = new ActionSystem(); foreach (var module in modules) { if (module.GetActions() == null) { continue; } ActionSystem.Add(module.GetActions()); } }
public override void Execute(ActionSystem system, ActionConfig config) { Logging.LogFormat("{0} {1} SpellActionBehavior", system.name, config.actionName); var spellSystem = system.GetComponent <SpellSystem>(); if (spellSystem.availableSpells.Count > 0) { foreach (var spell in spellSystem.availableSpells) { spell.Execute(spellSystem); } } }
public void Init() { healthSystem = GetComponent <HealthSystem>(); battleSystem = GetComponent <BattleSystem>(); actionSystem = GetComponent <ActionSystem>(); moveSystem = GetComponent <MoveSystem>(); specManager = GetComponent <SpecManager>(); graphicManager = GetComponent <GraphicManager>(); guardManager = GetComponent <GuardManager>(); healthSystem.Init(); battleSystem.Init(); graphicManager.Init(); }
public CombatSystem(Lua Lua, ActionSystem actSys, ActionInventorySystem actInvSys, AISystem aiSys, DropSystem dSys, EffectSystem eSys, EntityMaintenanceSystem eMainSys, ExperienceSystem xSys, ItemInventorySystem iSys, NameSystem nSys, PlayerSystem pSys, StatsSystem sSys) { actionSystem = actSys; aInventorySystem = actInvSys; aiSystem = aiSys; dropSystem = dSys; effectSystem = eSys; entityMaintenanceSystem = eMainSys; experienceSystem = xSys; inventorySystem = iSys; nameSystem = nSys; playerSystem = pSys; statsSystem = sSys; lua = Lua; RegisterLuaFunctions(); }
private void OnMoveInput(GameEvent e) { var data = (InputMoveBehaviour.MoveData)e.EventData; // Crouching was toggled? if (!data.CrouchToggled) { return; } // Busy? if (ActionSystem.IsBusy(data.EntityID)) { return; } ToggleCrouch(data.EntityID); }
private void SetMenuOptions(int actorID, int itemID) { if (!MenuSystem.RemoveOptions(actorID, AllMenuOptions)) { return; } if (ActionSystem.IsBusy(actorID)) { return; } if (!ItemWithinRange(MenuSystem.DistanceToTarget(actorID))) { return; } var lockComp = this.EntityManager.GetComponent <LockComponent>(itemID); if (lockComp == null) { return; } bool unlockOptionExists = false; if (lockComp.IsPickable && !lockComp.PickLockAttempted(actorID)) // IF lock is pickable AND actor has not attempted to pick this lock... { var skill = this.EntityManager.GetComponent <SkillComponent>(actorID); if (skill != null && skill.PickLockLevel >= 0) // ...AND actor can pick locks THEN add option { MenuSystem.AddOption(actorID, RPGGameEvent.Menu_PickLock); unlockOptionExists = true; } } if (lockComp.HasKey && ActorHasKey(actorID, lockComp.KeyEntityID)) { MenuSystem.AddOption(actorID, RPGGameEvent.Menu_UseKey); unlockOptionExists = true; } if (!unlockOptionExists) { MenuSystem.AddOption(actorID, RPGGameEvent.Menu_Locked); } }
private void OnMoveInput(GameEvent e) { var data = (InputMoveBehaviour.MoveData)e.EventData; // Busy? if (ActionSystem.IsBusy(data.EntityID)) { return; } // Set running var run = this.EntityManager.GetComponent <RunComponent>(data.EntityID); if (run == null) { return; } run.Running = data.Running; }
private void SetMenuOptions(int actorID, int itemID) { if (!MenuSystem.RemoveOptions(actorID, AllMenuOptions)) { return; } if (ActionSystem.IsBusy(actorID)) { return; } if (!ItemWithinRange(MenuSystem.DistanceToTarget(actorID))) { return; } var trap = this.EntityManager.GetComponent <TrapComponent>(itemID); if (trap == null) { return; } // Not Detected if (!trap.IsDetectedBy(actorID)) { return; } // No disarm skill or already tried to disarm? var skill = this.EntityManager.GetComponent <SkillComponent>(actorID); if (skill == null || skill.TrapDisarmLevel == 0 || trap.DisarmAttempted(actorID)) { MenuSystem.AddOption(actorID, RPGGameEvent.Menu_TrapDetected); } else // Can try disarming { MenuSystem.AddOption(actorID, RPGGameEvent.Menu_DisarmTrap); } }
/// <summary> /// Sends modifications from consumable item to the ActionSystem and destroys the item from inventory /// </summary> /// <param name="index">index of Item</param> private void UseConsumable(int index) { if (_playerUnit == null) { return; } Consumable consumable = _playerInventory.GetItem(index) as Consumable; if (consumable != null) { ActionSystem.UseConsumable(_playerUnit, consumable, _playerUnit.positionGrid); if (!_typesOnCooldown.ContainsKey(consumable.Name)) { _typesOnCooldown.Add(consumable.Name, consumable.cooldown); } RemoveItem(index); } }
public EntityManager(StateMachine sMach, DropSystem dSys, PlayerSystem pS, StatsSystem sS, ItemSystem iS, StatModifierSystem mS, EffectSystem efS, EquipmentSystem eqS, AISystem aiS, GearSystem gS, ExperienceSystem xS, ItemInventorySystem invS, NameSystem nS, ProfessionSystem profS, ActionSystem actS, ActionInventorySystem aInvS, CombatSystem cSys, EntityMaintenanceSystem eMS) { stateSystem = sMach; dropSystem = dSys; entMaintenanceSystem = eMS; aInventorySystem = aInvS; combatSystem = cSys; playerSystem = pS; statsSystem = sS; itemSystem = iS; modifierSystem = mS; effectSystem = efS; equipmentSystem = eqS; aiSystem = aiS; gearSystem = gS; experienceSystem = xS; inventorySystem = invS; nameSystem = nS; professionSystem = profS; actionSystem = actS; }
private void OnMoveInput(GameEvent e) { var data = (InputMoveBehaviour.MoveData)e.EventData; // Busy? if (ActionSystem.IsBusy(data.EntityID)) { return; } var movement = this.EntityManager.GetComponent <MovementComponent>(data.EntityID); if (movement == null) { return; } // Set Movement Direction(s) var moveDir = MoveDirection.None; if (data.Forward) { moveDir = MoveDirection.Forward; } else if (data.Backward) { moveDir = MoveDirection.Backward; } if (data.Left) { moveDir = (MoveDirection)MoveDirection.Left.OrOption(moveDir, typeof(MoveDirection)); } else if (data.Right) { moveDir = (MoveDirection)MoveDirection.Right.OrOption(moveDir, typeof(MoveDirection)); } // Adjust velocity (just direction, not speed) movement.Velocity = GetDirection(moveDir); }
private void OnMoveInput(GameEvent e) { var data = (InputMoveBehaviour.MoveData)e.EventData; // Jump action? if (!data.Jump) { return; } // Busy? if (ActionSystem.IsBusy(data.EntityID)) { return; } // Jump var jump = this.EntityManager.GetComponent <JumpComponent>(data.EntityID); if (jump == null || jump.Jumping) { return; } // Add Y velocity and raise event var form = this.EntityManager.GetComponent <FormComponent>(data.EntityID); if (form != null) { jump.Jumping = true; form.NewJumpForce = jump.Velocity; this.EventManager.QueueEvent(RPGGameEvent.JumpStarted, new JumpData() { EntityID = data.EntityID }); } }
public void Basic() { var target = new Target(); var provider = new ActionProvider(); var context = new Context { target }; var system = new ActionSystem { new ActionAdd(), new ActionMultiply() }; system.Execute(provider, context); Assert.AreEqual(0, target.Value); provider.Add(new CommandAdd(2)); provider.Add(new CommandMultiply(2)); provider.ApplyQueued(); system.Execute(provider, context); Assert.AreEqual(4, target.Value); }
public void ProcessAction(ActionSystem ctx) { Unit[] targetUnits = new Unit[targets.Length]; for (int i = 0; i < targets.Length; i++) { targetUnits[i] = UnitManager.INSTANCE.unitLookup[targets[i]]; } bool needsNewGroup = false; UnitGroup group = targetUnits[0].associatedPathfindingGroup; for (int i = 1; i < targetUnits.Length; i++) { if (group != targetUnits[i].associatedPathfindingGroup) { needsNewGroup = true; } } if (group != null) { needsNewGroup = (targets.Length != group.associatedUnits.Count); } else { needsNewGroup = true; } if (needsNewGroup) { group = PathfindingManager.INSTANCE.formGroup(); foreach (Unit u in targetUnits) { group.AddUnit(u); } } group.targetPosition = targetPosition; group.UpdatePathfinding(); }
public override void Initialize() { ContentSystem contentSystem = ((ContentSystem)world.SystemManager.GetSystem<ContentSystem>()[0]); m_actionsystem = ((ActionSystem)world.SystemManager.GetSystem<ActionSystem>()[0]); Viewport viewport = contentSystem.GetViewport(); int toolbarwindowh = 360; undoTreeWindow = new Window(manager); undoTreeWindow.Init(); undoTreeWindow.Text = "History"; undoTreeWindow.Width = 160; undoTreeWindow.Height = (int)((float)viewport.Height - toolbarwindowh); undoTreeWindow.Top = toolbarwindowh; // height of toolbarwindow undoTreeWindow.Left = viewport.Width - undoTreeWindow.Width; undoTreeWindow.Visible = true; undoTreeWindow.CloseButtonVisible = false; undoTreeWindow.Click += new TomShane.Neoforce.Controls.EventHandler(OnWindowClickBehavior); undoTreeWindow.IconVisible = false; undoTreeWindow.AutoScroll = false; //toolbarWindow.BorderVisible = false; //toolbar.Movable = false; manager.Add(undoTreeWindow); undoTreeContainer = new UndoTreeContainer(manager, undoTreeWindow, m_gd, m_content); undoTreeContainer.Init(); undoTreeContainer.Width = viewport.Width-16; undoTreeContainer.Height = viewport.Height-16; undoTreeContainer.Parent = undoTreeWindow; undoTreeContainer.CanFocus = false; undoTreeContainer.Click += new TomShane.Neoforce.Controls.EventHandler(OnContainerClickBehavior); undoTreeContainer.MouseScroll += new TomShane.Neoforce.Controls.MouseEventHandler(OnContainerScrollBehaviour); //undoTreeContainer.MousePress += new TomShane.Neoforce.Controls.MouseEventHandler(OnContainerPanBehaviour); undoTreeContainer.MouseMove += new MouseEventHandler(OnContainerPanBehaviour); undoTreeContainer.DoubleClicks = false; /* viewMode = new RadioButton(manager); viewMode.Init(); viewMode.Parent = undoTreeWindow; viewMode.Width = undoTreeWindow.Width / 2; viewMode.Height = 24; viewMode.Left = 0; viewMode.Top = 24; viewMode.Checked = true; viewMode.Text = "Tree view"; viewMode.Click += new TomShane.Neoforce.Controls.EventHandler(ViewModeBehaviour); * */ sbVert = new ScrollBar(manager, Orientation.Vertical); sbVert.Init(); sbVert.Detached = false; sbVert.Parent = undoTreeWindow; sbVert.Height = undoTreeWindow.ClientHeight-16; sbVert.SetPosition(undoTreeWindow.ClientWidth - sbVert.Width, 0); sbVert.Anchor = Anchors.Top | Anchors.Right | Anchors.Bottom; sbVert.ValueChanged += new TomShane.Neoforce.Controls.EventHandler(ScrollBarValueChangedY); // sbVert.MouseScroll += new TomShane.Neoforce.Controls.MouseEventHandler(ScrollBarMouseScroll); sbVert.Range = scrollMax; sbVert.PageSize = 0; sbVert.Value = 0; sbVert.Visible = true; undoTreeWindow.Add(sbVert); sbHorz = new ScrollBar(manager, Orientation.Horizontal); sbHorz.Init(); sbHorz.Detached = false; sbHorz.Parent = undoTreeWindow; sbHorz.Width = undoTreeWindow.ClientWidth-16; sbHorz.SetPosition(0, undoTreeWindow.ClientHeight - sbHorz.Height); sbHorz.Anchor = Anchors.Left | Anchors.Right | Anchors.Bottom; sbHorz.ValueChanged += new TomShane.Neoforce.Controls.EventHandler(ScrollBarValueChangedX); sbHorz.Range = scrollMax; sbHorz.PageSize = 0; sbHorz.Value = 0; sbHorz.Visible = true; undoTreeWindow.Add(sbHorz); // undoTreeContainer.Click += new TomShane.Neoforce.Controls.EventHandler(OnClick); }
private void InitializeSystems() { Console.WriteLine("Initializing Game Systems"); professionSystem = new ProfessionSystem(); effectSystem=new EffectSystem(lua); equipmentSystem = new EquipmentSystem(); experienceSystem = new ExperienceSystem(); itemSystem = new ItemSystem(); inventorySystem = new ItemInventorySystem(); modifierSystem = new StatModifierSystem(); nameSystem = new NameSystem(lua); playerSystem = new PlayerSystem(nameSystem, stateSystem); gearSystem = new GearSystem(); statsSystem = new StatsSystem(); aInventorySystem = new ActionInventorySystem(lua, statsSystem); actionSystem = new ActionSystem(lua); aiSystem = new AISystem(); dropSystem = new DropSystem(dropMap); }