Пример #1
0
            public Graphic Get(VEntity owner)
            {
                Graphic graphic = this._queue.Count > 0 ? this._queue.Dequeue() : new Graphic(this.id);

                graphic.OnSpawn(owner);
                return(graphic);
            }
Пример #2
0
        private void HandleEntityAttrChanged(BaseEvent e)
        {
            UIEvent uiEvent = ( UIEvent )e;

            VEntity target   = uiEvent.entity;
            Attr    attr     = uiEvent.attr;
            object  oldValue = uiEvent.o0;
            object  newValue = uiEvent.o1;

            if (target == VPlayer.instance)
            {
                switch (attr)
                {
                case Attr.Gold:
                    this._root["gold"].asCom["text_gold"].asTextField.text = string.Empty + ( int )newValue;
                    break;

                case Attr.Exp:
                    GProgressBar expBar = this._root["exp_bar"].asProgress;
                    expBar.value    = ( int )newValue;
                    expBar.maxValue = VPlayer.instance.upgradeExpNeeded;
                    break;
                }
                this._skillPanel.OnEntityAttrChanged(target, attr, oldValue, newValue);
                this._statesPanel.OnEntityAttrChanged(target, attr, oldValue, newValue);
            }
            this._hudManager.OnEntityAttrChanged(target, attr, oldValue, newValue);
        }
Пример #3
0
        public void PopHurt(GComponent parent, VEntity target, float damage, bool crit)
        {
            string font = _sPlayerHurtFont;
            string str  = string.Empty + ( int )damage;

            this.Pop(parent, target, font, str);
        }
Пример #4
0
        private void Pop(GComponent parent, VEntity target, string font, string text)
        {
            parent.AddChild(this);

            this._numberText.fontName = font;
            this._numberText.text     = text;
            this._numberText.position = new Vector2(-this._numberText.size.x * 0.5f, 0);

            this._pointInWorld = target.position;
            this._offsetHeight = target.size.y;
            this.UpdatePosition();

            this._tweenPos.x = 0;
            this._tweenPos.y = 0;
            float toX = 0;
            float toY = JITTER_FACTOR.y;

            this.alpha = 1;
            DOTween.To(() => new Vector2(this._tweenPos.x, this._tweenPos.y), val =>
            {
                this._tweenPos.x = val.x;
                this._tweenPos.y = val.y;
            }, new Vector2(toX, toY), 1.6f).OnUpdate(this.UpdatePosition).SetTarget(this).SetUpdate(false);

            this.TweenFade(0, 0.8f).SetDelay(0.8f)
            .OnUpdate(this.UpdatePosition).SetUpdate(false)
            .OnComplete(this.OnCompleted);
        }
Пример #5
0
        public void OnSkillAttrChanged(VEntity target, Skill skill, Attr attr, object oldValue, object newValue)
        {
            if (target != VPlayer.instance)
            {
                return;
            }

            if (skill == VPlayer.instance.commonSkill)
            {
                return;
            }

            GComponent skillGrid = this.GetSkillGrid(skill.id);
            GLoader    loader    = skillGrid["n2"].asLoader;

            switch (attr)
            {
            case Attr.Lvl:
            case Attr.Cooldown:
                loader.grayed    = skill.property.lvl < 0;
                loader.touchable = skill.CanUse();
                if (skill.property.lvl < 0)
                {
                    skillGrid["mask"].asImage.fillAmount = 0;
                }
                else
                {
                    skillGrid["mask"].asImage.fillAmount = skill.cd <= 0 ? 0 : skill.property.cooldown / skill.cd;
                }
                break;
            }
        }
Пример #6
0
        private void HandleSpawnEntity(BaseEvent baseEvent)
        {
            SyncEvent   e     = ( SyncEvent )baseEvent;
            EntityParam param = e.entityParam;

            switch (e.entityType)
            {
            case "Bio":
                VEntity entity = CUser.id == param.uid
                                                                                 ? this._entityManager.CreatePlayer(param)
                                                                                 : this._entityManager.CreateBio(param);

                if (entity == VPlayer.instance)
                {
                    //hero.fsm.enableDebug = true;
                    this.camera.target = entity;
                }
                break;

            case "Missile":
                this._entityManager.CreateMissile(param);
                break;

            case "FoxFire":
                this._entityManager.CreateBio <VFoxFire>(param);
                break;
            }
        }
Пример #7
0
        public static void EntityCreated(VEntity target)
        {
            UIEvent e = Get();

            e.type   = UIEventType.ENTITY_CREATED;
            e.entity = target;
            e.Invoke();
        }
Пример #8
0
        public static void EntityDestroied(VEntity target)
        {
            UIEvent e = Get();

            e.type   = UIEventType.ENTITY_DESTROIED;
            e.entity = target;
            e.Invoke();
        }
Пример #9
0
        public static void EntityDie(VEntity target, VEntity killer)
        {
            UIEvent e = Get();

            e.type   = UIEventType.ENTITY_DIE;
            e.entity = target;
            e.killer = killer;
            e.Invoke();
        }
Пример #10
0
 public Graphic Get(VEntity owner, string id)
 {
     if (!this._pool.TryGetValue(id, out GraphicPool pool))
     {
         pool           = new GraphicPool(id);
         this._pool[id] = pool;
     }
     return(pool.Get(owner));
 }
Пример #11
0
        public static void SkillUseFailed(VEntity caster, Skill skill, VEntity target)
        {
            UIEvent e = Get();

            e.type   = UIEventType.SKILL_USE_FAILED;
            e.entity = caster;
            e.skill  = skill;
            e.target = target;
            e.Invoke();
        }
Пример #12
0
        public void OnEntityAttrChanged(VEntity target, Attr attr, object oldValue, object newValue)
        {
            HUD hud;

            if (!this._idToHud.TryGetValue(target.rid, out hud))
            {
                return;
            }

            hud.OnEntityAttrChanged(attr, oldValue, newValue);
        }
Пример #13
0
        public static void AttrChanged(VEntity target, Attr attr, object oldValue, object newValue)
        {
            UIEvent e = Get();

            e.type   = UIEventType.ATTR_CHANGED;
            e.entity = target;
            e.attr   = attr;
            e.o0     = oldValue;
            e.o1     = newValue;
            e.Invoke();
        }
Пример #14
0
        public void OnEntityAttrChanged(VEntity target, Attr attr, object oldValue, object newValue)
        {
            GObject gObject = this._root["a_" + ( int )attr];

            if (gObject == null)
            {
                return;
            }

            GTextField tf = gObject.asTextField;

            tf.text = string.Empty + newValue;
        }
Пример #15
0
 public void OnEntityAttrChanged(VEntity target, Attr attr, object oldValue, object newValue)
 {
     switch (attr)
     {
     case Attr.SkillPoint:
         int count = VPlayer.instance.numSkills;
         for (int i = 1; i < count; i++)
         {
             GComponent skillGrid = this._skillGrids[i - 1];
             skillGrid.GetController("c1").selectedIndex = ( int )newValue > 0 ? 1 : 0;
         }
         break;
     }
 }
Пример #16
0
 public override void OnExit()
 {
     if (this._decal != null)
     {
         this._decal.markToDestroy = true;
         this._decal = null;
     }
     this._skill = null;
     if (this._lastTarget != null)
     {
         this._lastTarget.graphic.material.SetDefaultMaterial(false);
         this._lastTarget = null;
     }
     UIEvent.DropSkill();
 }
Пример #17
0
        private void HandleSkillAttrChanged(BaseEvent e)
        {
            UIEvent uiEvent = ( UIEvent )e;
            VEntity target  = uiEvent.entity;

            if (target != VPlayer.instance)
            {
                return;
            }
            Skill  skill    = uiEvent.skill;
            Attr   attr     = uiEvent.attr;
            object oldValue = uiEvent.o0;
            object newValue = uiEvent.o1;

            this._skillPanel.OnSkillAttrChanged(target, skill, attr, oldValue, newValue);
        }
Пример #18
0
        private void DestroyEnties()
        {
            int count = this._entities.Count;

            for (int i = 0; i < count; i++)
            {
                VEntity entity = this._entities[i];
                if (!entity.markToDestroy)
                {
                    continue;
                }

                entity.OnRemoveFromBattle();

                switch (entity)
                {
                case VBio bio:
                    this._bios.Remove(bio);
                    this._idToBio.Remove(bio.rid);
                    break;

                case VMissile missile:
                    this._missiles.Remove(missile);
                    this._idToMissile.Remove(missile.rid);
                    break;

                case Effect effect:
                    this._effects.Remove(effect);
                    this._idToEffect.Remove(effect.rid);
                    break;
                }

                this._entities.RemoveAt(i);
                this._idToEntity.Remove(entity.rid);
                this._gPool.Push(entity);
                --i;
                --count;
            }
        }
Пример #19
0
        protected void ReSize(int aCapacity)
        {
            aCapacity = CHashHelper.MGetPrime(aCapacity);
            var aNewEntities = new VEntity[aCapacity];
            var aNewValues   = new Value[aCapacity];
            int i            = 0;
            int o            = 0;

            while (i < m_EndIndex)
            {
                if (m_Entities[i].m_Hashcode < 0)
                {
                    ++i;
                    continue;
                }

                aNewEntities[o] = m_Entities[i];
                aNewValues[o]   = m_Values[i];
                ++o;
                ++i;
            }
            var aNewBuckets = new int[aCapacity];

            i = 0;
            while (i < o)
            {
                int a = aNewEntities[i].m_Hashcode % aCapacity;
                aNewEntities[i].m_Next = aNewBuckets[a] - 1;
                aNewBuckets[a]         = i + 1;
            }
            m_freeList = -1;
            m_EndIndex = m_Count = o;
            m_Buckets  = aNewBuckets;
            m_Entities = aNewEntities;
            m_Values   = aNewValues;
        }
Пример #20
0
        public void UpdateState(UpdateContext context)
        {
            int count = this._bios.Count;

            for (int i = 0; i < count; i++)
            {
                VEntity entity = this._bios[i];
                entity.UpdateState(context);
            }

            count = this._missiles.Count;
            for (int i = 0; i < count; i++)
            {
                VEntity entity = this._missiles[i];
                entity.UpdateState(context);
            }

            count = this._effects.Count;
            for (int i = 0; i < count; i++)
            {
                VEntity entity = this._effects[i];
                entity.UpdateState(context);
            }
        }
Пример #21
0
 internal void OnDespawn()
 {
     this.target = null;
 }