Ejemplo n.º 1
0
        public void UpgradeMage()
        {
            if (Player.Data.GetCurrency() < Data.GetUpgradePrice())
            {
                return;
            }
            Player.DecreaseCurrency(Data.GetUpgradePrice());
            Data.UpgradeMage();
            switch (Data.GetElement())
            {
            case Element.Air:
                Player.AchievementManager.RegisterEvent(AchievementType.AirMage, Data.GetLevel() + 1);
                break;

            case Element.Fire:
                Player.AchievementManager.RegisterEvent(AchievementType.FireMage, Data.GetLevel() + 1);
                break;

            case Element.Earth:
                Player.AchievementManager.RegisterEvent(AchievementType.EarthMage, Data.GetLevel() + 1);
                break;

            case Element.Water:
                Player.AchievementManager.RegisterEvent(AchievementType.WaterMage, Data.GetLevel() + 1);
                break;

            default:
                break;
            }
            //Do not spam with events
            if ((Data.GetLevel() < 50 && Data.GetLevel() % 10 == 0) || Data.GetLevel() % 5 == 0)
            {
                AnalyticsManager.MageUpgraded(this);
            }
            if (_building != null)
            {
                _building.DisplayRangeObject();
                _building.StartHighlighting();
            }
        }
Ejemplo n.º 2
0
        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;
            }
        }