Esempio n. 1
0
        public void Eject(bool withDrag)
        {
            if (!_building || !_building.IsOccupied())
            {
                return;
            }

            StartAnimation();
            transform.position = _basePosition;
            if (withDrag)
            {
                Data.SetState(MageState.Dragged);
            }
            else
            {
                Data.SetState(MageState.Idle);
            }
            _building.EjectMageInside();
            SetBuildingActive(false);
            _building = null;
            Data.EjectFromOccupiedBuilding();
            StartCoroutine(GenerateCurrency());

            if (Data.ProfileButton.GetComponent <Toggle>().isOn&& Player.MageButtons.MageMenuOpen)
            {
                SetHightlighActive(true);
            }
        }
Esempio n. 2
0
        private void ReleaseDraggedMage()
        {
            this.transform.localScale = originalSize;
            StartAnimation();
            Data.SetState(MageState.Idle);
            StartCoroutine(GenerateCurrency());
            RaycastHit hitObject;
            var        hit = Physics.Raycast(transform.position, Camera.main.transform.forward,
                                             out hitObject, Mathf.Infinity, MageDropMask);

            if (hit)
            {
                if (hitObject.collider.gameObject.tag.Equals("Tower") || hitObject.collider.gameObject.tag.Equals("Shrine"))
                {
                    var building = hitObject.collider.gameObject.GetComponent <MageAssignableBuilding>();
                    PutIntoBuilding(building);
                }
                else
                {
                    SetBuildingActive(false);
                    _building = null;
                }
            }
            else
            {
                transform.position = _basePosition;
            }

            foreach (var building in Player.GetSceneReferenceManager().AllAssignableBuildings)
            {
                building.Slot.SetActive(false);
                building.StopHighlighting();
            }
        }
Esempio n. 3
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;
            }
        }