Пример #1
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;
            }
        }