Пример #1
0
        public Entity AddCharacterView(CharacterView newView)
        {
            var component = CreateComponent <CharacterViewComponent>(ViewComponentIds.CharacterView);

            component.View = newView;
            return(AddComponent(ViewComponentIds.CharacterView, component));
        }
Пример #2
0
        public void initialize(Camera canvasCamera, CharacterInstance attachToCharacter)
        {
            this.m_canvasCamera        = canvasCamera;
            base.transform.localScale  = Vector3.one;
            this.CharacterAttached     = attachToCharacter;
            this.m_targetCharacterView = PlayerView.Binder.RoomView.getCharacterViewForCharacter(this.CharacterAttached);
            if (this.CharacterAttached.IsPlayerCharacter)
            {
                this.BossBarRoot.SetActive(false);
                this.PlayerBarRoot.SetActive(true);
                this.EnemyBarRoot.SetActive(false);
                this.m_activeProgressBar = this.PlayerHpSlider;
            }
            else if (this.CharacterAttached.IsBoss)
            {
                this.BossBarRoot.SetActive(true);
                this.PlayerBarRoot.SetActive(false);
                this.EnemyBarRoot.SetActive(false);
                this.m_activeProgressBar = this.BossHpSlider;
            }
            else
            {
                this.BossBarRoot.SetActive(false);
                this.PlayerBarRoot.SetActive(false);
                this.EnemyBarRoot.SetActive(true);
                this.m_activeProgressBar = this.EnemyHpSlider;
            }
            float v = MathUtil.Clamp01(attachToCharacter.CurrentHp / attachToCharacter.MaxLife(true));

            this.m_activeProgressBar.setNormalizedValue(v);
        }
Пример #3
0
 public void Init(CharacterView characterView, Transform atbRuler)
 {
     transform.localScale = Vector3.one;
     this.characterView   = characterView;
     gauge         = characterView.character.atbGauge;
     this.atbRuler = atbRuler;
 }
 public void setTarget(CharacterInstance targetCharacter)
 {
     this.TargetCharacter         = targetCharacter;
     this.m_targetCharacterView   = PlayerView.Binder.RoomView.getCharacterViewForCharacter(this.TargetCharacter);
     this.m_velocityMovingAverage = Vector3.zero;
     this.m_facingMovingAverage   = Vector3.zero;
 }
Пример #5
0
        public override void Load(ContentManager content)
        {
            view       = new CharacterView(content, stats.animations, 200, 200, 200, 200, stats);
            model.view = view;
            view.Scale = 0.6f;
            view.BoundRect(World, stats.size.X, stats.size.Y);
            view.BoundBox.UserData      = this;
            view.Layer                  = 100;
            view.FramesPerRow           = 10;
            view.BoundBox.Friction      = 0;
            view.BoundBox.IgnoreGravity = true;
            AddView(view);
            model.faceRight = true;
            model.inAir     = true;

            view.BoundBox.CollisionCategories = Category.Cat11;
            view.BoundBox.CollidesWith        = Category.All & ~Category.Cat11;
            view.BoundBox.OnCollision        += Collision;
            view.BoundBox.OnSeparation       += Seperation;

            view.Position = model.position;

            pad.OnNavigation    += Navigation;
            pad.OnHitkeyDown    += HitKeyDown;
            pad.OnHitKeyUp      += HitKeyUp;
            pad.OnSuperkeyDown  += SuperKeyDown;
            pad.OnSuperKeyUp    += SuperKeyUp;
            pad.OnShieldkeyDown += ShieldKeyDown;
            pad.OnShieldKeyUp   += ShieldKeyUp;

            AddController(moves);
            Screen.soundController.LoadCharacterGameSounds(content, stats);
        }
Пример #6
0
        public async Task DealDamageAsync()
        {
            // Arrange
            var id        = Guid.NewGuid();
            var character = new Character("SomeName", new HitPoints(42));
            var damages   = new DealDamage[]
            {
                new DealDamage {
                    DamageType = DamageTypes.Fire, Hp = 1
                },
                new DealDamage {
                    DamageType = DamageTypes.Cold, Hp = 2
                }
            };

            _characterRepository.Setup(x => x.GetByIdAsync(It.Is <Guid>(expected => expected == id)))
            .ReturnsAsync(character);
            _characterRepository.Setup(x => x.SaveAsync(It.IsAny <Character>()));
            _eventBus.Setup(x => x.PublishAsync <CharacterView>(It.IsAny <CharacterView>()));
            // Act
            CharacterView result = await _instance.DealDamageAsync(id, damages);

            // Assert
            _characterRepository.Verify(x => x.SaveAsync(It.Is <Character>(expected => expected == character)), Times.Once);
            _eventBus.Verify(x => x.PublishAsync <CharacterView>(It.Is <CharacterView>(expected => expected == result)), Times.Once);
            result.CurrentHp.Should().Be(39);
        }
        public async Task <CharacterView> GetCharacterViewAsync(int projectId, int characterId)
        {
            Expression <Func <CharacterGroup, GroupHeader> > groupHeaderSelector = group =>
                                                                                   new GroupHeader()
            {
                IsActive           = group.IsActive,
                CharacterGroupId   = group.CharacterGroupId,
                CharacterGroupName = group.CharacterGroupName,
                IsSpecial          = group.IsSpecial,
                ParentGroupIds     = group.ParentGroupsImpl,
            };

            var character = await Ctx.Set <Character>().AsNoTracking()
                            .Where(e => e.CharacterId == characterId && e.ProjectId == projectId)
                            .SingleOrDefaultAsync();

            var allGroups = await Ctx.Set <CharacterGroup>().AsNoTracking()
                            .Where(cg => cg.ProjectId == projectId && cg.IsActive)
                            .Select(groupHeaderSelector)
                            .ToDictionaryAsync(d => d.CharacterGroupId);

            var activeClaimPredicate = ClaimPredicates.GetClaimStatusPredicate(ClaimStatusSpec.Active);

            var view =
                new CharacterView()
            {
                CharacterId       = character.CharacterId,
                Name              = character.CharacterName,
                Description       = character.Description.Contents,
                UpdatedAt         = character.UpdatedAt,
                IsActive          = character.IsActive,
                InGame            = character.InGame,
                IsAcceptingClaims = character.IsAcceptingClaims,
                JsonData          = character.JsonData,
                ApprovedClaim     = await Ctx.Set <Claim>()
                                    .Where(claim => claim.CharacterId == characterId &&
                                           claim.ClaimStatus == Claim.Status.Approved).Select(
                    claim => new ClaimView()
                {
                    PlayerUserId = claim.PlayerUserId,
                    JsonData     = claim.JsonData,
                }).SingleOrDefaultAsync(),
                Claims = await Ctx.Set <Claim>().AsExpandable()
                         .Where(claim => claim.CharacterId == characterId &&
                                claim.ClaimStatus == Claim.Status.Approved).Select(
                    claim => new ClaimHeader()
                {
                    IsActive = activeClaimPredicate.Invoke(claim),
                }).ToListAsync(),
                DirectGroups = await Ctx.Set <CharacterGroup>()
                               .Where(group => character.ParentCharacterGroupIds.Contains(group.CharacterGroupId))
                               .Select(groupHeaderSelector).ToListAsync(),
            };

            view.AllGroups = view.DirectGroups
                             .SelectMany(g => g.FlatTree(group => group.ParentGroupIds._parentCharacterGroupIds.Select(id => allGroups[id])))
                             .Distinct()
                             .ToList();
            return(view);
        }
Пример #8
0
        public void Init()
        {
            _tutorial = new ExclusiveChoicesTutorial();
            _subView  = new ScanView(_person, DisableDialogueControls, InitDialogueOptions, () => !_isPresentingToUser);
            _subView.Init();
            _endConversationButton = new ImageTextButton(new Transform2(new Rectangle(-684, 960, 1380, 64)), _onFinished,
                                                         "Ok, great.",
                                                         "Convo/DialogueButton", "Convo/DialogueButton-Hover", "Convo/DialogueButton-Press")
            {
                TextColor     = Color.White,
                TextTransform = new Transform2(new Vector2(60, 960), new Size2(1380 - 684, 64)),
                TextAlignment = HorizontalAlignment.Left
            };

            _characterView = new CharacterView(_person, () => _shouldShowDialogueControls);
            _playerView    = new PlayerCharacterView(() => _shouldShowDialogueControls);

            _onNextDialogueElement = x => {
                _characterView.UpdateDialogue(x);
                _playerView.UpdateDialogue(x);
            };

            if (_person.IsImmediatelyTalking())
            {
                _person.StartImmediatelyTalking(StartDialogue);
            }
            else
            {
                InitDialogueOptions();
            }
        }
        private IEnumerator Test_Update()
        {
            PlayerView player = Instantiate(playerPrefab).GetComponent <PlayerView>();

            player.Model = new PlayerModel(new PlayerData()
            {
                Name = "TestPlayer"
            });
            CharacterClass characterClass = new CharacterClass()
            {
                Name = "TestCharacterClass", HealthPoints = 10, CharacterSprite = "Character_Example_8"
            };
            CharacterView character = Instantiate(characterPrefab).GetComponent <CharacterView>();

            character.Model      = new CharacterModel(new CharacterData(), characterClass, player.Model, true);
            userInterface.Player = player;
            yield return(new WaitForSeconds(1));

            player.Selection = null;
            yield return(new WaitForSeconds(3));

            player.Selection = character;
            yield return(new WaitForSeconds(3));

            player.Selection = null;
            yield return(new WaitForSeconds(3));

            Destroy(character.gameObject);
            Destroy(player.gameObject);
            yield return(new WaitForSeconds(1));
        }
Пример #10
0
        public override void OnInspectorGUI()
        {
            base.OnInspectorGUI();
            CharacterView view = target as CharacterView;
            Character     cc   = view.Owner;

            if (cc == null)
            {
                return;
            }
            EditorGUILayout.TextField("ID", cc.ID.ToString());
            EditorGUILayout.TextField("Type", cc.Type.ToString());
            EditorGUILayout.TextField("GUID", cc.GUID.ToString());
            EditorGUILayout.TextField("Camp", cc.Camp.ToString());
            EditorGUILayout.TextField("FSM", cc.FSM.ToString());
            EditorGUILayout.TextField("AIState", cc.AIState.ToString());

            EditorGUILayout.ObjectField("Target", cc.Target == null ? null : cc.Target.View, typeof(CharacterView), true);
            EditorGUILayout.ObjectField("Obj", cc.Obj, typeof(CharacterView), true);
            EditorGUILayout.ObjectField("ObjTrans", cc.Obj, typeof(CharacterView), true);
            EditorGUILayout.ObjectField("AI", cc.AI, typeof(NodeTree), true);

            if (cc.CurrAttr != null)
            {
                view.Attr = cc.CurrAttr;
            }
        }
Пример #11
0
 public void SetLayerWeight(int index, float weight, CharacterView view)
 {
     Type       = FsmOutputType.LayerWeight;
     IntValue   = index;
     FloatValue = weight;
     View       = view;
 }
        private IEnumerator Test_DamageSelf()
        {
            CharacterView  character      = Instantiate(characterPrefab).GetComponent <CharacterView>();
            CharacterClass characterClass = new CharacterClass()
            {
                Name = "TestCharacterClass", HealthPoints = 10, CharacterSprite = "Character_Example_8"
            };

            character.Model = new CharacterModel(new CharacterData(), characterClass, null, true);
            yield return(new WaitForSeconds(1));

            IAbility ability = new AreaAbility()
            {
                Power       = 2, TargetWidth = 1, TargetHeight = 1,
                TargetTypes = new List <TargetType>()
                {
                    TargetType.Self
                }
            };

            ability.Cast(new UnityCharacterFinder(targetLayerMask), character.Model, character.Model.Position);
            yield return(new WaitForSeconds(1));

            Destroy(character.gameObject);
            yield return(new WaitForSeconds(1));
        }
Пример #13
0
    public void Init(Battle battle)
    {
        this.battle = battle;

        Battlefield battlefield = GameObject.Instantiate(battlefieldSource) as Battlefield;

        battlefield.transform.parent        = transform;
        battlefield.transform.localPosition = Vector3.zero;
        battlefield.transform.localRotation = Quaternion.identity;

        actionCardsPool.Init(actionCardSource);
        resultCardsPool.Init(resultCardSource);

        foreach (Character ally in battle.allies)
        {
            CharacterView characterView = GameObject.Instantiate(characterViewSource) as CharacterView;
            characterView.Init(ally);
            ally.atbGaugeFullEvent += ATBGaugeFull;
        }

        foreach (Character enemy in battle.enemies)
        {
            CharacterView characterView = GameObject.Instantiate(characterViewSource) as CharacterView;
            characterView.Init(enemy);
        }
    }
Пример #14
0
        private void CreateCharacterView(Character character)
        {
            CharacterView characterView = characterViewFactory.Create(character.Kind);

            PlacePositionHolderView(characterView, character.Position);
            TrackView(character, characterView);
        }
Пример #15
0
        protected override bool Trigger()
        {
            Vector3    origin = Skill.Caster.Avatar.GetBindPosition(Bind);
            RaycastHit hit;

            if (Physics.Raycast(origin, Skill.Caster.Dir, out hit, MaxDis))
            {
                Collider col = hit.collider;
                if (HitEffectID > 0)
                {
                    EffectData unit = GTWorld.Instance.Ect.LoadEffect(HitEffectID, 0, GTTransform.Create(hit.point, Vector3.zero), null, true);
                    unit.Release(HitEffectDuration);
                }
                CharacterView view = col.GetComponent <CharacterView>();
                if (view != null)
                {
                    if (Skill.Caster.Match(Affect, view.Owner))
                    {
                        for (int i = 0; i < Children.Count; i++)
                        {
                            Children[i].ApplyHitPoint = hit.point;
                            Children[i].ApplyHitDir   = Vector3.up;
                            Children[i].ClearAttackList();
                            Children[i].AddInAttackList(view.Owner);
                        }
                        End();
                    }
                }
            }
            return(base.Trigger());
        }
Пример #16
0
        public Transform FastGetBoneTransform(string boneName, CharacterView view)
        {
            Transform ret = null;

            if (view == CharacterView.ThirdPerson)
            {
                CheckP3Cache();
                foreach (TransformCache transformCache in _cacheP3)
                {
                    transformCache.Cache.TryGetValue(boneName, out ret);
                    if (ret != null)
                    {
                        break;
                    }
                }
            }
            else
            {
                CheckP1Cache();
                foreach (TransformCache transformCache in _cacheP1)
                {
                    transformCache.Cache.TryGetValue(boneName, out ret);
                    if (ret != null)
                    {
                        break;
                    }
                }
            }

            return(ret);
        }
Пример #17
0
        public void SetCharacterView(CharacterView view)
        {
            TextBoxSetPortraitMessage message = new TextBoxSetPortraitMessage();

            message.view = view;
            _connection.SendMessage(message);
        }
Пример #18
0
        public static void GetRangedCharacterProjectileSetup(CharacterInstance sourceCharacter, Vector3 targetWorldPt, out Vector3 projectileSpawnPt, out Vector3 projectileTargetPt, out float projectileCurveHeight)
        {
            Vector3       localPosition;
            CharacterView view       = PlayerView.Binder.RoomView.getCharacterViewForCharacter(sourceCharacter);
            Vector3       normalized = Vector3Extensions.ToXzVector3(targetWorldPt - sourceCharacter.PhysicsBody.Transform.position).normalized;

            if (view.ProjectileSpawnpoint != null)
            {
                localPosition = view.ProjectileSpawnpoint.localPosition;
            }
            else
            {
                localPosition = new Vector3(0f, 1.5f, 1.5f);
            }
            localPosition      = (Vector3)(localPosition * GetCharacterVisualScale(sourceCharacter));
            projectileSpawnPt  = ((sourceCharacter.PhysicsBody.Transform.position + normalized) + sourceCharacter.PhysicsBody.Transform.TransformVector(new Vector3(0f, 0f, -1f))) + sourceCharacter.PhysicsBody.Transform.TransformVector(localPosition);
            projectileTargetPt = new Vector3(targetWorldPt.x, 1.5f, targetWorldPt.z);
            if (sourceCharacter.Type == GameLogic.CharacterType.Yeti)
            {
                projectileCurveHeight = 3.5f;
            }
            else
            {
                projectileCurveHeight = 0f;
            }
        }
Пример #19
0
        private void OnSendImpact(CharacterInfo sender, int targetId, int impactId, Vector3 srcPos, float srcDir)
        {
            CharacterView senderView = EntityManager.Instance.GetCharacterViewById(sender.GetId());
            CharacterView targetView = EntityManager.Instance.GetCharacterViewById(targetId);

            if (null != senderView && null != targetView)
            {
                CharacterInfo target = WorldSystem.Instance.GetCharacterById(targetId);
                if (null != target)
                {
                    // 施法者能造成硬直且受击方没有霸体
                    ImpactInfo impactInfo = target.GetSkillStateInfo().GetImpactInfoById(impactId);
                    if (null == impactInfo)
                    {
                        return;
                    }
                    int forceLogicId = -1;
                    if (sender.CauseStiff && !target.SuperArmor && !target.UltraArmor)
                    {
                        // 正常造成硬直
                    }
                    else
                    {
                        forceLogicId = 0;
                        impactInfo.m_IsGfxControl = false;
                    }
                    // Npc需要根据体型和类型判定
                    if (target.IsNpc)
                    {
                        NpcInfo npcInfo = target.CastNpcInfo();
                        // 场景破坏物体单独处理
                        if (npcInfo.NpcType == (int)NpcTypeEnum.SceneObject)
                        {
                            forceLogicId = 1;
                            impactInfo.m_IsGfxControl = true;
                        }
                        // 处理体型
                        if (!impactInfo.ConfigData.TargetFigure.Contains(npcInfo.NpcFigure))
                        {
                            forceLogicId = 0;
                            impactInfo.m_IsGfxControl = false;
                        }
                    }
                    // 打断技能
                    if ((null != impactInfo && 0 != impactInfo.ConfigData.ImpactGfxLogicId && forceLogicId < 0) || forceLogicId > 0)
                    {
                        if (null != target.SkillController)
                        {
                            target.SkillController.ForceInterruptCurSkill();
                        }
                        else
                        {
                            LogSystem.Warn("{0} does't have a skillcontroller", target.GetName());
                        }
                    }
                    GfxSystem.QueueGfxAction(GfxModule.Impact.GfxImpactSystem.Instance.SendImpactToCharacter, senderView.Actor, targetView.Actor, impactId, srcPos.X, srcPos.Y, srcPos.Z, srcDir, forceLogicId);
                }
            }
        }
Пример #20
0
 public void SetValue(int hash, string name, float value, CharacterView view)
 {
     Type       = FsmOutputType.Float;
     Target     = name;
     TargetHash = hash;
     FloatValue = value;
     View       = view;
 }
Пример #21
0
        public void SetThridPerson()
        {
            WeaponControllerBaseImpl.SetThirdPerson();
            WardrobeControllerBaseImpl.SetThirdPerson();
            PropControllerBaseImpl.SetThirdPerson();

            _view = CharacterView.ThirdPerson;
        }
Пример #22
0
        public void SetFirstPerson()
        {
            WeaponControllerBaseImpl.SetFirstPerson();
            WardrobeControllerBaseImpl.SetFirstPerson();
            PropControllerBaseImpl.SetFirstPerson();

            _view = CharacterView.FirstPerson;
        }
Пример #23
0
        public void SetFirstPerson()
        {
            _weaponController.SetFirstPerson();
            _wardrobeController.SetFirstPerson();
            _propController.SetFirstPerson();

            _view = CharacterView.FirstPerson;
        }
Пример #24
0
        private List <FieldWithValue> GetFields(CharacterView character, Project project)
        {
            var projectFields = project.GetFieldsNotFilled().ToList();

            projectFields.FillFrom(character.ApprovedClaim);
            projectFields.FillFrom(character);
            return(projectFields);
        }
 public CharacterController(CharacterView view, Character character)
 {
     _view = view;
     _character = character;
     _character.OnDead += OnDead;
     _character.OnSkillStart += OnSkillStart;
     _character.Guard.OnChanged += OnGuardChanged;
 }
Пример #26
0
        public Entity ReplaceCharacterView(CharacterView newView)
        {
            var component = CreateComponent <CharacterViewComponent>(ViewComponentIds.CharacterView);

            component.View = newView;
            ReplaceComponent(ViewComponentIds.CharacterView, component);
            return(this);
        }
Пример #27
0
        public void SetThridPerson()
        {
            _weaponController.SetThirdPerson();
            _wardrobeController.SetThirdPerson();
            _propController.SetThirdPerson();

            _view = CharacterView.ThirdPerson;
        }
Пример #28
0
 public PlayerMoveControllerPhysics(CharacterView view, SpriteAnimator spriteAnimator, GameSettings settings)
 {
     _characterView      = view;
     _spriteAnimator     = spriteAnimator;
     _contactsPoller     = new ContactsPoller(_characterView.GetComponent <Collider2D>());
     _settings           = settings;
     _characterRigidbody = _characterView.GetComponent <Rigidbody2D>();
 }
Пример #29
0
 public void Execute(Action <FsmOutput> addOutput, CharacterView view, float stateSpeedBuff)
 {
     if (null != _action)
     {
         _action.Invoke(addOutput, _additionalValue * stateSpeedBuff, view);
         _action = null;
     }
 }
Пример #30
0
 private void Awake()
 {
     _characterControler = new CharacterController();
     _characterControler.SetCharacterModel(this, _character = GetComponent <CharacterView>());
     _characterWeapon = GetComponent <CharacterWeapon>();
     rb              = GetComponent <Rigidbody2D>();
     transfom        = GetComponent <Transform>();
     _spriteRenderer = GetComponent <SpriteRenderer>();
 }
Пример #31
0
 public override void Update(Action <FsmOutput> addOutput, CharacterView view, float stateSpeedBuff)
 {
     base.Update(addOutput, view, stateSpeedBuff);
     for (int i = 0; i < _currentCommandIndex; i++)
     {
         _outerCommand[i].Execute(addOutput, view, stateSpeedBuff);
     }
     _currentCommandIndex = 0;
 }
Пример #32
0
 public void SetCharacter(CharacterId id)
 {
     var characterData = CharacterDb._.Find(id);
     if (characterData == null) return;
     if (CharacterView != null) Destroy(CharacterView.gameObject);
     CharacterView = characterData.CharacterView.Instantiate();
     CharacterView.transform.SetParent(transform, false);
     CharacterView.transform.localPosition = Vector3.zero;
 }
Пример #33
0
        public void RemoveCharacter()
        {
            if (CharacterView == null)
            {
                Debug.LogError("view not exist.");
                return;
            }

            Destroy(CharacterView.gameObject);
            CharacterView = null;
        }
Пример #34
0
 public Character( CharacterView characterView )
 {
     this.characterView = characterView;
 }