private const double GARBAGE_COLLECTION_VALUE = 120; // - (distanceLeft^1.5), range of values is about 200 to 180 /// <summary> /// Add possible responses to "chooser", based on the situation in "game" and in "statesManager" /// </summary> public override void AddResponseOptions(Game game, StatesManager statesManager, ActionsChooser chooser) { if (this.myPirate.State != PirateState.Drunk || (game.GetPirateSpawnOn(this.myPirate) != null && game.GetPirateSpawnOn(this.myPirate).Owner == Owner.Enemy)) //If my pirate isn't drunk it doesn't need help { return; } // try to sail to "collect" the pirate foreach (Pirate free in game.GetMyPirates(PirateState.Free)) { var sailOptions = game.GetCompleteSailOptions(free, this.myPirate, Terrain.CurrentTreasureLocation); foreach (var pair in sailOptions) { if (sailOptions[0].Value > pair.Value) //sail only if it's actually better than staying in place { ActionsPack ap = ActionsPack.NewCommandPack(game, new RamCommand(free, this.myPirate, pair.Key), base.Id); ap.AddMyPirate(myPirate); double distanceFromSpawnModifier = Utils.Pow(Game.ManhattanDistance(free.InitialLocation, free), 1.5); double timeModifier = Utils.Pow(game.TurnsUntilSober - this.myPirate.TurnToSober, 1.5); double value = Utils.Max(GARBAGE_COLLECTION_VALUE - timeModifier - distanceFromSpawnModifier - Utils.Pow(pair.Value, 1.5), 35); ap.BurnInformation("Made in GarbageCollection event, saving {0}, Value: {1:F3}", this.myPirate.Id, value); chooser.AddActionsPack(ap, value); } } } }
//private void OnCollisionEnter(Collision collision) //{ // InputManager im = collision.gameObject.GetComponent<InputManager>(); // if (im != null && !isTaken) // { // isTaken = true; // im.states.rpg.potions[potionType.index].Enqueue(this); // SetRigidbodyActivity(false); // PutInHand(im); // } //} void PutInHand(StatesManager states) { transform.parent = states.potionHand; transform.localPosition = Vector3.zero; transform.localRotation = Quaternion.identity; gameObject.SetActive(false); }
void Awake() { states = GetComponent <StatesManager> (); c = FindObjectOfType <Camera> (); Events.OnSpecialEffect += OnSpecialEffect; Events.OnLightTrip += OnLightTrip; }
void MenuLogoutPressed(object sender, EventArgs e) { ClientSettings.Current.Settings.Token = null; ClientSettings.Current.Save(); StatesManager.ActivateGameStateAsync("Login"); }
private void InitializeDataBinding() { // Log data _qsoLog = new QSOLog(Properties.Settings.Default.LogPath); qsoGrid.ItemsSource = _qsoLog.QSOs; // Type data _typeDataDb = new TypeDataDb(); _bandsManager = new BandsManager(_typeDataDb); _modesManager = new ModesManager(_typeDataDb); _countriesManager = new CountriesManager(_typeDataDb); _statesManager = new StatesManager(_typeDataDb); _bandsManager.LoadAndUpdate(); _modesManager.LoadAndUpdate(); _countriesManager.LoadAndUpdate(); _statesManager.LoadAndUpdate(); bandTxt.ItemsSource = _bandsManager.Bands; modeTxt.ItemsSource = _modesManager.Modes; countryTxt.ItemsSource = _countriesManager.Countries; stateTxt.ItemsSource = _statesManager.States; }
public void HurtPeople(GameObject collider) { if (collider.layer != 8) { StatesManager states = collider.GetComponent <StatesManager>(); if (states != null) { if (!states.isDodge) { states.Hurt(damage); Instantiate(blood, transform.position, Quaternion.LookRotation(-transform.forward)); } } else { Instantiate(sparks, transform.position, Quaternion.LookRotation(-transform.forward)); } ShieldScript shieldScript = collider.GetComponent <ShieldScript>(); if (shieldScript != null) { gameObject.SetActive(false); } } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { StatesManager.LoadStatesPage(gvStates, rptPager, 1, ddlPageSize); } }
public void Init(StatesManager states) { animator = GetComponent <Animator>(); head = animator.GetBoneTransform(HumanBodyBones.Head); body = animator.GetBoneTransform(HumanBodyBones.Chest); rightHand = animator.GetBoneTransform(HumanBodyBones.RightHand); leftHand = animator.GetBoneTransform(HumanBodyBones.LeftHand); leftArm = animator.GetBoneTransform(HumanBodyBones.LeftLowerArm); this.states = states; this.states.OnDrink += States_OnDrink; if (states.name != "Controller Warrior(Clone)" && states.name != "Controller Archer(Clone)" && states.name != "Controller Mage(Clone)") { return; } commandCursor = ObjectPool.Instance.GetObject("Command Object(Clone)", body).transform; MageCommandPointIdentifier mpi = commandCursor.GetComponentInChildren <MageCommandPointIdentifier>(); if (mpi != null) { commandCursorArt = mpi.gameObject; commandCursorArt.SetActive(false); } //Debug.Log("animator event initialized"); }
public virtual void SetPossessionAs(GameObject newCreature) { if (_currentPossession) { //Kill _currentPossession; Destroy(_currentPossession); } _currentPossession = newCreature; if (_cc) { _cc.target = newCreature.transform; } _aim = newCreature.GetComponent <AIManager>(); if (_aim) { _aim.isControllingCreature = false; _aim.MyAgent.enabled = false; if (_aim.crownSpawnLocation && CrownPrefab) { Instantiate(CrownPrefab, _aim.crownSpawnLocation); } } _sm = newCreature.GetComponent <StatesManager>(); if (_sm) { _sm.DoTransition(moveState); playerMoveState pms = moveState as playerMoveState; if (pms && _aim) { pms.speed = _aim.MyAgent.speed * 2; } } }
void playerEntityManager_NeedToShowInventory(object sender, InventoryEventArgs e) { if (StatesManager.CurrentState.Name != "Inventory") { StatesManager.ActivateGameStateAsync("Inventory", true); } }
private void StartGameManager() { try { ResourcesLoaderManager = transform.GetComponentInChildren <ResourcesLoaderManager>(); ResourcesLoaderManager.Init(); EventsManager.Init(); StatesEvents = new StatesEvents(); StatesManager = new StatesManager(); StatesManager.ChangeCurrentState(new Begin()); StatesManager.ChangeCurrentState(new Run()); PlayerEvents = new PlayerEvents(); TimerManager = new TimerManager(); PauseManager = new PauseManager(); DefeatUIManager = new DefeatUIManager(); LevelsManager = new LevelsManager(); LeaderBoardManager = new LeaderBoardManager(); //test LeaderBoardManager.GetRequestAndInstantiateIntoCanvas(); } catch (Exception e) { Debug.LogException(e); } }
public void DestroySelf(StatesManager states) { states.currentPotion = null; transform.parent = null; SetRigidbodyActivity(true); StartCoroutine(StayBeforeDeactivation()); }
public virtual void OnStart() { //Debug.Log("StartBase"); _isActive = true; states = owner.GetComponent <StatesManager>(); rb = owner.GetComponent <Rigidbody>(); ih = FindObjectOfType <UserInput>(); }
protected virtual void Awake() { InitUI(); states = GetComponent <StatesManager>(); states.Init(); rpg = states.rpg; AssignUI(); }
public virtual void PickUp(StatesManager states) { //Debug.Log("pickUpLaDey"); owner = states; SetRigidbodyActivity(false); states.rpg.generalStuff.Add(this); gameObject.SetActive(false); }
public override void OnEnabled(GameState previousState) { var settings = _iocContainer.Get <SettingsComponent>(); var inputManager = _iocContainer.Get <InputsManager>(); inputManager.MouseManager.MouseCapture = false; settings.isGameRunning = this.PreviousGameState == StatesManager.GetByName("InGameMenu"); }
void MenuContinuePressed(object sender, EventArgs e) { var inputManager = _ioc.Get <InputsManager>(); inputManager.MouseManager.MouseCapture = _captureMouse; StatesManager.ActivateGameStateAsync("Gameplay"); }
protected void lbDelete_Click(object sender, EventArgs e) { ImageButton linkButton = new ImageButton(); linkButton = (ImageButton)sender; bool result = StatesManager.DeleteStates(Convert.ToInt32(linkButton.CommandArgument)); StatesManager.LoadStatesPage(gvStates, rptPager, 1, ddlPageSize); }
void Awake() { states = GetComponent <StatesManager>(); ui = GetComponent <UIManager>(); slot = GetComponent <SlotManager>(); block = GetComponent <BlockManager>(); pool = GetComponent <PoolManager>(); stats = GetComponent <StatsManager>(); }
private void ServerComponentOnConnectionStausChanged(object sender, TcpConnectionStatusEventArgs e) { if (e.Status == TcpConnectionStatus.Disconnected) { var vars = _ioc.Get <RealmRuntimeVariables>(); vars.MessageOnExit = "Server connection was interrupted. " + _serverComponent.LastErrorText; StatesManager.ActivateGameState("MainMenu"); } }
void MenuExitPressed(object sender, EventArgs e) { var vars = _ioc.Get <RealmRuntimeVariables>(); vars.DisposeGameComponents = true; vars.MessageOnExit = null; WithPreservePreviousStates = false; StatesManager.ActivateGameStateAsync("MainMenu"); }
void OnDestroy() { Events.OnSpecialEffect -= OnSpecialEffect; Events.OnLightTrip -= OnLightTrip; states = null; c = null; styles = null; head = null; info = null; }
public void UsePotion(StatesManager states) { gameObject.SetActive(true); states.rpg.StartCoroutine( states.rpg.PotionEffect( potionType.index, potionType.value, potionType.duration)); }
void serverComponent_ConnectionStausChanged(object sender, ServerConnectionStatusEventArgs e) { if (e.Status == TcpConnectionStatus.Disconnected && e.Final) { var serverComponent = _ioc.Get <ServerComponent>(); var guiManager = _ioc.Get <GuiManager>(); logger.Info("Disconnected from the server. Error text: {0}", serverComponent.LastErrorText); guiManager.MessageBox("Can't connect to the server. " + serverComponent.LastErrorText, "error"); StatesManager.ActivateGameStateAsync("MainMenu"); } }
//All chunks have been created on the client (They can be rendered) void worldChunks_LoadComplete(object sender, EventArgs e) { _ioc.Get <IWorldChunks>().LoadComplete -= worldChunks_LoadComplete; StatesManager.ActivateGameStateAsync("Gameplay"); //Say to server that the loading phase is finished inside the client _ioc.Get <ServerComponent>().EnterTheWorld(); //Start a client chunk resync phase. _ioc.Get <IWorldChunks>().ResyncClientChunks(); }
public override void PickUp(StatesManager states) { if (!isTaken) { isTaken = true; states.rpg.potions[potionType.index].Enqueue(this); SetRigidbodyActivity(false); PutInHand(states); } }
public virtual void Drop() { gameObject.SetActive(true); transform.position = owner.aem.body.position; SetRigidbodyActivity(true); if (owner.rpg.generalStuff.Contains(this)) { owner.rpg.generalStuff.Remove(this); } owner = null; }
/// <summary> /// Add possible responses to "chooser", based on the situation in "game" and in "statesManager" /// </summary> public override void AddResponseOptions(Game game, StatesManager statesManager, ActionsChooser chooser) { //Counts how many of the pirates in the cluster carry treasure, will be used for event value. List <Pirate> treasurePiratesInCluster = this.hotspot.Intersect(game.GetMyPirates(PirateState.CarryingTreasure)).ToList(); int valueInCluster = treasurePiratesInCluster.Sum(pirate => pirate.CarriedTreasureValue); if (valueInCluster == 0) { return; } // the pirates in the threat zone List <Pirate> enemiesInCluster = game.GetEnemyPiratesInAttackRange(this.hotspot, PirateState.Free).Union( game.GetEnemyPiratesInAttackRange(this.hotspot, PirateState.Drunk)).ToList(); //Checks if there is an enemy in the cluster already, if so - sends in the cavalry! foreach (Pirate enemy in enemiesInCluster) { if (enemy.State == PirateState.Drunk && game.GetPirateSpawnOn(enemy.Location) != null && game.GetPirateSpawnOn(enemy.Location).Owner != Owner.Me) { continue; } foreach (Pirate myPirate in game.GetMyPirates(PirateState.Free)) { var sailOptions = game.GetCompleteSailOptions(myPirate, enemy, myPirate.DefenseDuration == 0 && !Game.InAttackRange(myPirate, enemy, enemy.AttackRadius), Terrain.CurrentTreasureLocation); foreach (var pair in sailOptions) { if (sailOptions[0].Value > pair.Value) //sail only if it's actually better than staying in place { ActionsPack ap = ActionsPack.NewCommandPack(game, new SailCommand(myPirate, pair.Key), this.Id); ap.AddEnemyPirate(enemy); double value = BASE_VAL + valueInCluster * TREASURE_VAL + (this.hotspot.Count - treasurePiratesInCluster.Count) * NO_TREASURE_VAL + enemiesInCluster.Count * ENEMY_VAL - Utils.Pow(pair.Value, 1.25); if (this.hotspot.Contains(myPirate)) { value += IS_HOME_VAL; } if (statesManager.GetState <ImpendingVictoryState>().IsVictoryIncoming) { value *= IMPENDING_VICTORY_MULT; } ap.BurnInformation("Made in AntiTeroristEvent against {0}, Value: {1:F3}", enemy.Id, value); chooser.AddActionsPack(ap, value); } } } } }
private void StartLoseSequence() { if (!levelLoading) { losePopup.GetComponent <Canvas>().enabled = true; levelLoading = true; Invoke("LoadFirstLevel", loadLevelDelay); InputHandler inputHandler = player.GetComponentInChildren <InputHandler>(); StatesManager statesManager = player.GetComponent <StatesManager>(); inputHandler.freezeMovement = true; statesManager.Stop(); } }
void MenuMultiplayerPressed(object sender, EventArgs e) { var guiManager = _ioc.Get <GuiManager>(); var webApi = _ioc.Get <ClientWebApi>(); if (string.IsNullOrEmpty(webApi.Token)) { guiManager.MessageBox("Server authorization was failed. Did you confirm your email? (check the spam folder). You will unable to play multiplayer without confirmation.", "error"); return; } _vars.SinglePlayer = false; StatesManager.ActivateGameStateAsync("SelectServer"); }