public void AssignActions() { upgradeActions = new ActionWithEvent[3]; var upgradeAction1 = new ActionWithEvent { Function = delegate { _startedUpgrading = true; _lastUpgradeTime = 0; }, TriggerType = EventTriggerType.PointerDown }; var upgradeAction2 = new ActionWithEvent { Function = delegate { _startedUpgrading = false; }, TriggerType = EventTriggerType.PointerUp }; var upgradeAction3 = new ActionWithEvent { Function = delegate { UpgradeMage(); }, TriggerType = EventTriggerType.PointerClick }; upgradeActions[0] = upgradeAction1; upgradeActions[1] = upgradeAction2; upgradeActions[2] = upgradeAction3; }
// Use this for initialization protected virtual void Start() { MenuOpen = false; Menu = null; isHighlightOn = false; ActionWithEvent action = new ActionWithEvent(); action.Function = delegate { if (InsideMage != null) { InsideMage.Eject(false); } }; action.TriggerType = EventTriggerType.PointerClick; options[0].actions[0] = action; if (!InsideMage) { ParticleEffect.Stop(); } }
public void PutIntoBuilding(MageAssignableBuilding building) { if (building.SetMageInside(this)) { AssignActions(); Data.OccupyBuilding(building.GetId()); Data.SetState(MageState.Active); _building = building; SetBuildingActive(true); if (_isHighlightOn) { SetHightlighActive(false); // _building.StartHighlighting(ElementController.Instance.GetColor(this.Data.GetElement())); _building.StartHighlighting(); _building.DisplayRangeObject(); Player.BuildingMenuSpawner.SpawnMenu(_building); } if (Player == null) { Player = Camera.main.GetComponent <Player> (); } _building.options [1].actions = upgradeActions; var shrine = building as Shrine; if (shrine) { ActionWithEvent skillAction = new ActionWithEvent(); skillAction.Function = delegate { if (this.CanCast()) { _isCalling = true; Player.SkillCall(this); } }; skillAction.TriggerType = EventTriggerType.PointerDown; _building.options[2].actions[0] = skillAction; ActionWithEvent skillAction2 = new ActionWithEvent(); skillAction2.Function = delegate { if (this.CanCast() && _isCalling) { _isCalling = false; Player.CastSkill(); var Button = Player.BuildingMenuSpawner.OpenMenu.GetButton(2); Button.GetComponent <CoolDown>().Cooldown(ElementController.Instance.GetElementSkillCooldown(Data.GetElement()), Time.time); CooldownStart = Time.time; } //_building.Menu.CloseMenu(_building.Menu); }; skillAction2.TriggerType = EventTriggerType.PointerUp; _building.options[2].actions[1] = skillAction2; //_building.options[2].sprite=skillSprite //putting skill in options[] } if (building.MenuOpen) { building.Menu.OnInsideMagePrefabChanged(); } } else { transform.position = _basePosition; } }
public void AssignActions() { //for player upgrade upgrade1Actions = new ActionWithEvent[3]; ActionWithEvent upgrade1Action1 = new ActionWithEvent(); upgrade1Action1.Function = delegate { _startedUpgrading1 = true; _lastUpgradeTime1 = 0; }; upgrade1Action1.TriggerType = EventTriggerType.PointerDown; ActionWithEvent upgrade1Action2 = new ActionWithEvent(); upgrade1Action2.Function = delegate { _startedUpgrading1 = false; }; upgrade1Action2.TriggerType = EventTriggerType.PointerUp; ActionWithEvent upgrade1Action3 = new ActionWithEvent(); upgrade1Action3.Function = delegate { UpgradePlayer(); }; upgrade1Action3.TriggerType = EventTriggerType.PointerClick; upgrade1Actions[0] = upgrade1Action1; upgrade1Actions[1] = upgrade1Action2; upgrade1Actions[2] = upgrade1Action3; //for idle currency upgrade upgrade2Actions = new ActionWithEvent[3]; ActionWithEvent upgrade2Action1 = new ActionWithEvent(); upgrade2Action1.Function = delegate { _startedUpgrading2 = true; _lastUpgradeTime2 = 0; }; upgrade2Action1.TriggerType = EventTriggerType.PointerDown; ActionWithEvent upgrade2Action2 = new ActionWithEvent(); upgrade2Action2.Function = delegate { _startedUpgrading2 = false; }; upgrade2Action2.TriggerType = EventTriggerType.PointerUp; ActionWithEvent upgrade2Action3 = new ActionWithEvent(); upgrade2Action3.Function = delegate { UpgradeIdleGenerated(); }; upgrade2Action3.TriggerType = EventTriggerType.PointerClick; upgrade2Actions[0] = upgrade2Action1; upgrade2Actions[1] = upgrade2Action2; upgrade2Actions[2] = upgrade2Action3; }