Пример #1
0
        private void BigButton_Click(object sender, RoutedEventArgs e)
        {
            Button   button   = (Button)sender;
            HeroView heroView = (HeroView)button.Content;

            heroView.HeroContext.Life = heroView.HeroContext.BaseLife;
        }
Пример #2
0
        private void popUpHeroChoiceGenerator()
        {
            this.popUp           = new Window();
            this.popUp.MaxHeight = 400;
            this.popUp.MaxWidth  = 900;
            ScrollViewer scrollViewer = new ScrollViewer();

            scrollViewer.VerticalScrollBarVisibility   = ScrollBarVisibility.Hidden;
            scrollViewer.HorizontalScrollBarVisibility = ScrollBarVisibility.Visible;
            StackPanel newStackPanel = new StackPanel();

            newStackPanel.Orientation = Orientation.Horizontal;

            foreach (Hero hero in GameViewModel.Instance.MainCastle.Heroes)
            {
                Button bigButton = new Button();
                bigButton.Background  = System.Windows.Media.Brushes.Transparent;
                bigButton.BorderBrush = System.Windows.Media.Brushes.Transparent;
                bigButton.Click      += BigButton_Click;
                bigButton.Width       = 300;
                bigButton.Height      = 350;

                HeroView newHeroView = new HeroView(hero);
                newHeroView.Width  = 300;
                newHeroView.Height = 350;
                newHeroView.SelectHeroButton.Visibility = Visibility.Collapsed;

                bigButton.Content = newHeroView;
                newStackPanel.Children.Add(bigButton);
            }

            scrollViewer.Content = newStackPanel;
            this.popUp.Content   = scrollViewer;
            this.popUp.Show();
        }
Пример #3
0
        public override void Init()
        {
            base.Init();
            this.m_HeroItem = base.LoadPrefabCache("HeroItem");
            this.AllButton  = this.transform.Find("Anchor/AllButton");
            this.Employ     = this.AllButton.Find("Employ");
            this.All        = this.AllButton.Find("All");
            this.Power      = this.AllButton.Find("Power");
            this.Agile      = this.AllButton.Find("Agile");
            this.IQ         = this.AllButton.Find("IQ");
            this.BG         = this.transform.Find("Bottom/BG").GetComponent <UISprite>();
            this.BackButton = this.transform.Find("Anchor/BackButton");
            Transform root = this.transform.Find("Anchor/HeroPanel/HeroView");

            this.favouredHeroView = new HeroView(root);
            this.Number           = this.transform.Find("Bottom/BattleNum/Number").GetComponent <UILabel>();
            this.PlayGame         = this.transform.Find("Bottom/PlayGame");
            Transform root2 = this.transform.Find("Bottom/HeroPanel/HeroView");

            this.selectedHeroView = new SelectHeroView(root2);
            UIEventListener.Get(this.BackButton.gameObject).onClick = new UIEventListener.VoidDelegate(this.ClickBackBtnEvent);
            UIEventListener.Get(this.All.gameObject).onClick        = new UIEventListener.VoidDelegate(this.ShowTypeHero);
            UIEventListener.Get(this.Power.gameObject).onClick      = new UIEventListener.VoidDelegate(this.ShowTypeHero);
            UIEventListener.Get(this.Agile.gameObject).onClick      = new UIEventListener.VoidDelegate(this.ShowTypeHero);
            UIEventListener.Get(this.IQ.gameObject).onClick         = new UIEventListener.VoidDelegate(this.ShowTypeHero);
            UIEventListener.Get(this.Employ.gameObject).onClick     = new UIEventListener.VoidDelegate(this.ShowTypeHero);
            UIEventListener.Get(this.PlayGame.gameObject).onClick   = new UIEventListener.VoidDelegate(this.ClickGoToGame);
            this.m_AlphaController = this.transform.GetComponent <TweenAlpha>();
        }
Пример #4
0
    /// <summary>
    ///
    /// </summary>
    /// <param name="hurt">等于0:miss,大于0:红色减生命,小于0:绿色加生命</param>
    public void Fresh(object data)
    {
        HeroView view = (HeroView)data;
        int      hurt = view.preHPChangeValue;

        if (hurt == 0)
        {
            Miss();
        }
        if (hurt < 0)
        {
            Hurt(hurt);
        }
        if (hurt > 0)
        {
            Reply(hurt);
        }

        RectTransform viewRtf = view.GetComponent <RectTransform>();

        rtf.anchoredPosition = viewRtf.anchoredPosition;
        Vector2 endPos = new Vector2(rtf.anchoredPosition.x, rtf.anchoredPosition.y + viewRtf.sizeDelta.y / 2);

        UpAni(endPos);
    }
Пример #5
0
    public override void OnStartClient()
    {
        try
        {
            base.OnStartClient();
            loadDeck();
            ShuffleDeck();

            Debug.Log("player ctrller client started");
            ctrl          = GameObject.Find("BattleController");
            handCanvas    = GameObject.Find("handPlayer");
            enemyCanvas   = GameObject.Find("handEnemy");
            playerField   = GameObject.Find("playerField");
            enemyField    = GameObject.Find("enemyField");
            turnButton    = GameObject.Find("turn_button");
            Logger        = GameObject.Find("game_logger");
            heroContainer = GameObject.Find("playerHeroContainer");
            heroView      = GameObject.Find("playerHeroView").GetComponent <HeroView>();

            ctrl.GetComponent <BattleController>().registerPlayers(gameObject);
            if (hasAuthority)
            {
                StartCoroutine(wait4AllPlayer());
                Debug.Log("initializing");
            }
        }
        catch (System.Exception e)
        {
            Debug.Log(e);
            throw;
        }
    }
Пример #6
0
        private void CreateHero()
        {
            HeroView view = UnityEngine.Object.Instantiate(_rootView.HeroPrefab, Vector2.zero, Quaternion.identity);

            Hero.Ctx heroCtx = new Hero.Ctx
            {
                lineCount          = _rootView.LevelConfig.LineCount,
                maxHeath           = 3,
                currentHealth      = 3,
                view               = view,
                availableColors    = _rootView.LevelConfig.AvailableColors,
                availableMeshes    = _rootView.LevelConfig.AvailableMeshes,
                lineWidth          = _rootView.LevelConfig.LineWidth,
                continueGame       = _rootView.GameSpeed.ContinueGame,
                blockSwipeCommand  = _blockSwipeCommand,
                hideTutorialView   = _hideTutorialView,
                restartScene       = _ctx.restartScene,
                returnToStoryScene = _ctx.returnToStoryScene,
                isPaused           = () => _rootView.Paused,
                stopRun            = _rootView.GameSpeed.SlowDownGame,
            };
            _mainHero = new Hero(heroCtx);
            _mainHero.InitializeHero();
            ConfigCamera(view.transform);
        }
Пример #7
0
 void OpenHeroMiniView()
 {
     if (!view)
     {
         view = HeroView.Create(ViewStructHelper.Instance.rightPanel);
     }
     view.Activate(this);
 }
Пример #8
0
        private void NewHeroView()
        {
            HeroView newHeroView = new HeroView();

            newHeroView.DataContext = GameViewModel.Instance.MainCastle.Army.Hero;
            newHeroView.SelectHeroButton.Visibility = System.Windows.Visibility.Collapsed;
            view.Units.Children.Add(newHeroView);
        }
Пример #9
0
 private void OnHeroAdded(HeroRemoteDataModel heroModel)
 {
     if (heroModel != null)
     {
         SpawnHero(heroModel).Done((v) =>
         {
             _hero = v;
             heroModel.Group.ObserveAdd().Subscribe(OnAnimalAddToGroup).AddTo(Disposables);
         });
     }
 }
Пример #10
0
        public HeroViewModel(Hero hero)
        {
            View                  = new HeroView();
            this.Hero             = hero;
            this.View.DataContext = this.Hero;
            InventoryUC newIventoryUC = new InventoryUC();

            newIventoryUC.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch;
            newIventoryUC.DataContext         = this.Hero;
            this.View.HeroInfoSP.Children.Add(newIventoryUC);
            InitEquipView();
        }
Пример #11
0
        private IPromise <HeroView> SpawnHero(HeroRemoteDataModel hero)
        {
            Promise <HeroView> promise = new Promise <HeroView>();

            GameObject instance = _container.InstantiatePrefab(_projectSettings.HeroPrefab);
            HeroView   heroView = instance.GetComponent <HeroView>() ??
                                  _container.InstantiateComponent <HeroView>(instance);

            heroView.Initialize(hero);

            promise.Resolve(heroView);

            return(promise);
        }
Пример #12
0
        private void GenerateUI(Hero attackingHero, Hero defendingHero)
        {
            HeroView AllyHeroView = new HeroView();

            AllyHeroView.HeroInfoSP.Visibility       = System.Windows.Visibility.Collapsed;
            AllyHeroView.SelectHeroButton.Visibility = System.Windows.Visibility.Collapsed;
            AllyHeroView.DataContext = attackingHero;
            foreach (Skill skill in attackingHero.Skills)
            {
                SkillViewModel newSkill;
                switch (skill.Type)
                {
                case "Attaque":
                    newSkill = new SkillViewModel(skill);
                    newSkill.View.SkillLaunchButton.Click += AttaqueButton_Click;
                    newSkill.View.CounterTB.Visibility     = System.Windows.Visibility.Collapsed;
                    newSkill.View.SetValue(Grid.ColumnProperty, 0);
                    View.SkillsGrid.Children.Add(newSkill.View);
                    break;

                case "Parade":
                    newSkill = new SkillViewModel(skill);
                    newSkill.View.SkillLaunchButton.Click += ParadeButton_Click;
                    newSkill.View.SetValue(Grid.ColumnProperty, 1);
                    View.SkillsGrid.Children.Add(newSkill.View);
                    break;

                case "Feinte":
                    newSkill = new SkillViewModel(skill);
                    newSkill.View.SkillLaunchButton.Click += FeinteButton_Click;
                    newSkill.View.SetValue(Grid.ColumnProperty, 2);
                    View.SkillsGrid.Children.Add(newSkill.View);
                    break;

                default:
                    break;
                }
            }
            this.View.AllyHeroSP.Children.Add(AllyHeroView);
            this.View.AllyHeroAttributesSP.DataContext   = this.AttackingHero;
            this.View.EnnemyHeroAttributesSP.DataContext = this.DefendingHero;

            HeroView EnnemyHeroView = new HeroView();

            EnnemyHeroView.HeroInfoSP.Visibility       = System.Windows.Visibility.Collapsed;
            EnnemyHeroView.SelectHeroButton.Visibility = System.Windows.Visibility.Collapsed;
            EnnemyHeroView.DataContext      = defendingHero;
            this.View.ValidateButton.Click += ValidateButton_Click;
            this.View.EnnemyHeroSP.Children.Add(EnnemyHeroView);
        }
Пример #13
0
        public void SetUp()
        {
            input = Substitute.For <Input>();

            var heroPrefab   = AssetDatabase.LoadAssetAtPath <GameObject>("Assets/Prefabs/Hero.prefab");
            var heroInstance = Object.Instantiate(heroPrefab);

            heroView = heroInstance.GetComponent <HeroView>();

            var map                = MapFactory.AMap.Build();
            var hero               = new HeroSpawner().CreateHero(map, 0, 0);
            var heroMovement       = new HeroMovement(hero, map);
            var movementController = new MovementController(heroView, heroMovement);

            heroView.Configure(input, movementController);
        }
 public HeroUnitController( EntityController.Select entityControllerSelect,
     HeroViewPresentor unitViewPresenter,
     BaseUnit.UnitCharacteristics unitCharacteristics,
     EntityController.GetTarget getTarget,
     EntityController.Faction faction,
     DeathDestroy updateDeath, 
     EntityController.HeroResurrect heroResurrect,
     BaraksModel.SetUpdeteCharacteristicsDelegate setUpdeteCharacteristicsDelegate )
     : base(entityControllerSelect, unitViewPresenter, unitCharacteristics, getTarget, faction, updateDeath, setUpdeteCharacteristicsDelegate)
 {
     this.updateDeath = updateDeath;
     EffectsController effectsController = new EffectsController();
     this.heroResurrect = heroResurrect;
     unitBehaviour.CallDeathFSMEvent();
     unitBehaviour = new HeroBehaviour( getTarget, faction, unitViewPresenter, animationController );
     unitModel = new HeroUnit( "Unit", unitCharacteristics, SpellInit( effectsController ), faction, effectsController, _UpdateCharacteristics, UpdateDeath, LevelUpEffect, setUpdeteCharacteristicsDelegate, DeleteVisualEffect );
     unitView = new HeroView( unitViewPresenter, Selected, GetDamage, ((HeroUnit)unitModel).GetXp );
 }
Пример #15
0
        public InventorySetViewModel(Hero hero)
        {
            this.Hero = hero;
            this.View = new InventorySetPopUp();
            HeroViewModel newHeroViewModel = new HeroViewModel(this.Hero);

            newHeroViewModel.View.InventoryHeroButton.Visibility = System.Windows.Visibility.Collapsed;
            this.HeroView                     = newHeroViewModel.View;
            this.HeroView.Height              = this.View.Grid.Height - 100;
            this.HeroView.HeroImage.Height    = 150;
            this.HeroView.ButtonSP.Visibility = System.Windows.Visibility.Collapsed;
            this.View.HeroViewSP.Children.Add(HeroView);

            EquipmentListing EquipmentListing = new EquipmentListing();

            EquipmentListing.Controller.initEquipView(hero);
            this.view.allObjectSP.Children.Add(EquipmentListing);
        }
Пример #16
0
 public override void Destroy()
 {
     this.selectIndex = 0;
     this.favouredHeroView.Clear();
     this.selectedHeroView.Clear();
     this.AllButton        = null;
     this.All              = null;
     this.Power            = null;
     this.Agile            = null;
     this.IQ               = null;
     this.Employ           = null;
     this.BG               = null;
     this.PlayGame         = null;
     this.BackButton       = null;
     this.Number           = null;
     this.favouredHeroView = null;
     this.selectedHeroView = null;
     this.m_HeroItem       = null;
     base.Destroy();
 }
 public HeroController(tunbasedbattlerContext dbContext)
 {
     this.heroService = new HeroService(dbContext);
     heroView         = new HeroView();
 }
Пример #18
0
 public override void  Activate(object controller)
 {
     curHeroView = (HeroView)controller;
     gameObject.SetActive(true);
     sqadAddViewList.ForEach((SquadAddView squadAddView) => squadAddView.UpdateAcces(curHeroView.curHero.GetArmy()));
 }
Пример #19
0
    //public event UnityAction addSelectNinjaClick;



    private void Awake()
    {
        instence = this;
    }
Пример #20
0
        public void SetCurrentPhase(Phase active_phase)
        {
            switch (active_phase)
            {
            case Phase.IdlePhase:
                break;

            case Phase.DraftPhase:

                //fade in/out animation ui
                _fadingBannerView.SetAnimationUI(true, Phase.DraftPhase, CurrentPlayerTurn);

                //set turn to 1
                _currentTurnCount    = 1;
                _turnNumberText.text = "turn: " + _currentTurnCount;

                _draftUi.SetActive(true);
                _phaseText.text = "Draft Phase";

                //reset draft text
                PlayerOneDraftedText.text = "Drafted: 0/5";
                PlayerTwoDraftedText.text = "Drafted: 0/5";

                //disable plan ui
                _planUi.SetActive(false);

                DraftHeroUnits();

                break;

            case Phase.PlanPhase:

                Player.Instance.ClearActionIcons();

                //check if turn is player 1s turn
                SetPlayerTurn(CurrentPlayerTurn);

                //fade in/out animation ui
                _fadingBannerView.SetAnimationUI(true, Phase.PlanPhase, CurrentPlayerTurn);

                CleanLists();

                //enable grid ui
                _gridUi.SetActive(true);

                _draftUi.SetActive(false);
                _resolveUi.SetActive(false);
                _phaseText.text = "Planning Phase";

                _planUi.SetActive(true);

                //reset player actions on new turn
                PlayerOneActionsText.text = "Actions: 0/3";
                PlayerTwoActionsText.text = "";

                Player.Instance.ResetPlayerActionCounts();

                foreach (var hero in HeroListP1)
                {
                    var heroView = hero.GetComponent <HeroView>();
                    heroView.SetUI(true);
                }
                foreach (var hero in HeroListP2)
                {
                    var heroView = hero.GetComponent <HeroView>();
                    heroView.SetUI(true);
                }

                //if phase was drafted phase, place units
                if (CurrentPhase == Phase.DraftPhase)
                {
                    PlaceDraftedUnits();
                }

                break;

            case Phase.ResolvePhase:

                //hide player turn text/set empty
                _playerTurnText.text = "";

                //fade in/out animation ui
                _fadingBannerView.SetAnimationUI(true, Phase.ResolvePhase, CurrentPlayerTurn);

                //disable plan ui
                _planUi.SetActive(false);

                //enable resolve ui
                _resolveUi.SetActive(true);

                //set action ended to true so that animations can play
                HasActionEnded = true;

                //hide stats on heroes and green check
                foreach (GameObject g in HeroListP2)
                {
                    HeroView heroView = g.GetComponent <HeroView>();

                    heroView.SetUI(false);
                    heroView.SetAction(false);
                }

                _phaseText.text = "Resolve Phase";
                StartCoroutine(Player.Instance.ResolveActions());
                break;

            default:
                throw new ArgumentOutOfRangeException("no phase found for: " + active_phase);
            }

            //set current phase to active phase
            CurrentPhase = active_phase;
        }
Пример #21
0
 public HeroViewModel(Hero hero)
 {
     View      = new HeroView();
     this.Hero = hero;
     EventGenerator();
 }