示例#1
0
    public override void Trigger()
    {
        base.Trigger();

        if (buff == null)
        {
            Debug.LogError("未设置效果Buff:" + name);
        }

        if (number > 0)
        {
            //Debug.Log("添加Buff:" + buff.name);
            for (int i = 0; i < number; i++)
            {
                BuffManager.AddBuff(targetU, buff);
            }
        }
        else if (number < 0)
        {
            //Debug.Log("移除Buff:" + buff.name);
            for (int i = 0; i < Mathf.Abs(number); i++)
            {
                BuffManager.RemoveBuff(targetU, buff);
            }
        }
    }
        public void InitCreature(BaseCreature creature, Location loc)
        {
            Template          = creature;
            EntityName        = Template.creatureName;
            Hash              = EntityManager.Instance.AddEntity(this);
            EntityBuffManager = new BuffManager(Hash);
            foreach (var buff in Template.buffs)
            {
                EntityBuffManager.AddBuff(new BuffHandler(Hash, Hash, buff.Hash));
            }
            m_spriteRenderer.sprite = Template.sprite;
            m_attribute             = Template.attribute;
            HealthPoints            = MaxHealthPoints;

            foreach (var skill in Template.skills)
            {
                SkillHashes.Add(skill.Hash);
            }
            NextCastSkillID = 0;

            //var h = EntitySprite.bounds.size.y;
            //hpBar.transform.localPosition += new Vector3(0, h, 0);

            hpBar.enabled             = false;
            mask_hpEffect.alphaCutoff = 1;
            mask_hp.alphaCutoff       = 1;
            MoveToTile(loc, 0, true);

            hpBar.enabled = true;
            CreatureHpChangeAnimation(MaxHealthPoints, MaxHealthPoints, 1);
        }
        public override void Execute()
        {
            foreach (var entity in BuffManager.Entitys)
            {
                var buffs = BuffManager.GetBuffs <T>(entity);

                for (var i = 0; i < buffs.Count; i++)
                {
                    var buff = buffs[i];

                    if (buff.LastTriggerTime - buff.Duration >=
                        buff.TriggerInterval)
                    {
                        buff.LastTriggerTime = buff.Duration;

                        BuffManager.AddBuff(entity, new TDamageBuff()
                        {
                            Entity = buff.Entity,
                            Type   = buff.Type,
                            Value  = buff.Value,
                        });
                    }

                    BuffManager.SetBuffData(entity, buff, i);
                }
            }
        }
示例#4
0
        public override bool Execute(SkillArgs Args)
        {
            BuffManager.AddBuff(new TriggerBuff(new TriggerBuffDescriptor(Args.Skill.Name, 5, 0.5f, 0, true,
                                                                          new NpcAttrModifyInfo(NpcAttrIndex.Speed, 0.5f, 0), Args.Skill.Radius, 1),
                                                Args.Position, Args.Master.Team.Opposite()));

            return(true);
        }
        public void 添加buff()
        {
            _startMemory = GC.GetTotalMemory(false);
            Stopwatch stop = new Stopwatch();

            stop.Start();
            for (int i = 0; i < 5000; i++)
            {
                _buffManage.AddBuff(_entity, new TestBuff() /*name = i.ToString()*/ }
                {
    public override void Affect(GameObject obj)
    {
        BuffManager bm = obj.GetComponent <BuffManager>();

        if (bm != null)
        {
            bm.AddBuff(
                new DamageOverTimeBuff("Poison", DamageType.POISON, damagePerSec, length)
                );
        }
    }
        protected override Action Execute()
        {
            if (BuffType == null)
            {
                return(null);
            }

            _buff = (IBuffDataComponent)this.DynamicInputCreateInstance(BuffType);
            if (_isAddBuff)
            {
                return(() => BuffManager.AddBuff(Target, _buff));
            }

            return(() => BuffManager.RemoveBuff(Target, _buff));
        }
示例#8
0
    /// <summary>
    /// The function used for dealing damage or healing a unit
    /// </summary>
    /// <param name="intake">A list of Intakes detailing the incoming damage/heal</param>
    public void ApplyIntake(ref List <Intake> intake)
    {
        for (int i = 0; i < intake.Count; i++)
        {
            if (intake[i].intakeType == Intake.IntakeType.DAMAGE)
            {
                float incoming = intake[i].GetModifiedAmmount();
                print("Took " + incoming + " " + intake[i].GetTypeString() + " Damage.");
                float newhp        = currentHealth - incoming;
                float postHitHpPCT = newhp / maxHealth;
                if (preHitHpPCT <= postHitHpPCT)
                {
                    preHitHpPCT = postHitHpPCT; impactChangeTimer = impactChangeDelay;
                }

                currentHealth = newhp;
                //if (currentHealth <= 0) Destroy(gameObject);
                //applying invuln
                if (intake[i].intakeClass != Intake.IntakeClass.IGNORE_INVULN && incoming > 0)
                {
                    BuffManager.Invulnerability invuln = new BuffManager.Invulnerability();
                    invuln.startDuration = invulnLength;
                    buffManager.AddBuff(invuln);
                }
            }
            else if (intake[i].intakeType == Intake.IntakeType.HEAL)
            {
                float incoming = intake[i].GetModifiedAmmount();
                print("Took " + incoming + " " + intake[i].GetTypeString() + " Healing.");

                float newhp        = currentHealth - incoming;
                float postHitHpPCT = newhp / maxHealth;
                preHitHpPCT = postHitHpPCT;
                if (currentHealth > maxHealth)
                {
                    currentHealth = maxHealth;
                }
                currentHealth = newhp;
                if (currentHealth > maxHealth)
                {
                    currentHealth = maxHealth;
                }
            }
        }
    }
        public override void Execute(IEntity entity)
        {
            var buffs = BuffManager.GetBuffs <IMechanicBuff>(entity, x => x.MechanicsType == MechanicsType.Health);

            var enumerator = buffs.GetEnumerator();

            if (!enumerator.MoveNext())
            {
                return;
            }

            var buff = enumerator.Current;

            if (buff.Value <= 0)
            {
                BuffManager.AddBuff(entity, new Death());
            }
        }
示例#10
0
        public void InitAbioticEntity(BaseAbiotic template, Location loc)
        {
            Template          = template;
            EntityName        = Template.abioticName;
            Hash              = EntityManager.Instance.AddEntity(this);
            EntityBuffManager = new BuffManager(Hash);
            foreach (var buff in Template.buffs)
            {
                EntityBuffManager.AddBuff(new BuffHandler(Hash, Hash, buff.Hash));
            }
            m_spriteRenderer.sprite = Template.sprite[template.sprite.Length.Random()];
            m_attribute             = Template.attribute;
            HealthPoints            = MaxHealthPoints;

            //EntitySprite.transform.localScale = new Vector3(0.1f / EntitySprite.size.x, 0.2f / EntitySprite.size.y);

            MoveToTile(loc, MoveCost, true);
            transform.localPosition = Vector3.zero;
            DropAnimation();
        }
示例#11
0
        private void Update()
        {
            if (isDebug)
            {
                if (IsAdd)
                {
                    TestBuff buff;
                    if (IsPool)
                    {
                        buff = _buffManage.CreateAndAddBuff <TestBuff>(_entity, null);
                    }
                    else
                    {
                        buff = new TestBuff();
                        _buffManage.AddBuff(_entity, buff);
                    }

                    _buffs.Add(buff);
                }
                else
                {
                    if (_buffs.Count > 0)
                    {
                        for (var i = _buffs.Count - 1; i >= 0; i--)
                        {
                            var buff = _buffs[i];

                            if (IsPool)
                            {
                                _buffManage.RemoveBuffEx(_entity, buff);
                            }
                            else
                            {
                                _buffManage.RemoveBuff(_entity, buff);
                            }
                        }
                    }
                }
            }
        }
示例#12
0
            public void Dispose(bool postLoad, bool isReset)
            {
                try
                {
                    if (mWasFutureSim)
                    {
                        mSim.TraitManager.AddHiddenElement(TraitNames.FutureSim);
                    }

                    if (mSim.CreatedSim != null)
                    {
                        BuffManager buffManager = mSim.CreatedSim.BuffManager;
                        if ((buffManager != null) && (mBuffs != null))
                        {
                            foreach (BuffInstance buff in mBuffs)
                            {
                                buffManager.AddBuff(buff.Guid, buff.mEffectValue, buff.mTimeoutCount, buff.mTimeoutPaused, buff.mAxisEffected, buff.mBuffOrigin, false);
                            }
                        }

                        if ((mInventory != null) && (mSim.CreatedSim.Inventory != null))
                        {
                            Inventories.RestoreInventoryFromList(mSim.CreatedSim.Inventory, mInventory, true);
                        }

                        if (mDreamStore != null)
                        {
                            mDreamStore.Restore(mSim.CreatedSim);
                        }

                        if (mSafeStore != null)
                        {
                            mSafeStore.Dispose();
                        }

                        if (mSim.DeathStyle != SimDescription.DeathType.None)
                        {
                            Urnstone stone = Urnstones.FindGhostsGrave(mSim);
                            if (stone != null)
                            {
                                stone.GhostSetup(mSim.CreatedSim, true);
                            }
                        }

                        mSim.CreatedSim.ReservedVehicle = mReservedVehicle;
                    }
                }
                catch (Exception e)
                {
                    Common.Exception(mSim, null, "Inventory", e);
                }

                // Must be after the opportunities are restored
                if ((mOpportunitiesChanged != null) && (OpportunityTrackerModel.gSingleton != null))
                {
                    OpportunityTrackerModel.gSingleton.OpportunitiesChanged = mOpportunitiesChanged;
                }

                try
                {
                    if (!postLoad)
                    {
                        if ((mSim.CreatedSim != null) &&
                            (mSim.CreatedSim.OpportunityManager != null) &&
                            (mSim.CreatedSim.OpportunityManager.Count > 0))
                        {
                            OpportunityTrackerModel.FireOpportunitiesChanged();
                        }
                    }
                }
                catch (Exception e)
                {
                    Common.Exception(mSim, null, "FireOpportunitiesChanged", e);
                }

                EventTracker.sCurrentlyUpdatingDreamsAndPromisesManagers = false;

                mSim.mGenealogy = mGenealogy;

                if (mDoll != null)
                {
                    mDoll.mOwner = mSim;

                    if (SimTypes.IsSelectable(mSim))
                    {
                        try
                        {
                            mDoll.OnOwnerBecameSelectable();
                        }
                        catch (Exception e)
                        {
                            Common.Exception(mSim, e);

                            SimDescription sim = mDoll.GetLiveFormSimDescription();
                            if (sim != null)
                            {
                                new FixInvisibleTask(sim).AddToSimulator();
                            }
                        }
                    }
                }

                if ((mSim.CreatedSim != null) && (mSim.CreatedSim.Motives != null))
                {
                    if (mAcademicPerformance != -101)
                    {
                        mSim.CreatedSim.Motives.CreateMotive(CommodityKind.AcademicPerformance);
                        Motive motive = mSim.CreatedSim.Motives.GetMotive(CommodityKind.AcademicPerformance);
                        if (motive != null)
                        {
                            motive.Value = mAcademicPerformance;
                        }
                    }

                    if (mUniversityStudy != -101)
                    {
                        mSim.CreatedSim.Motives.CreateMotive(CommodityKind.UniversityStudy);
                        Motive motive = mSim.CreatedSim.Motives.GetMotive(CommodityKind.UniversityStudy);
                        if (motive != null)
                        {
                            motive.Value = mUniversityStudy;
                        }
                    }
                }

                Relationships.RestoreRelations(mSim, mRelations);

                if ((mSim.TraitChipManager != null) && (mChips != null))
                {
                    for (int i = 0; i < mChips.Length; i++)
                    {
                        if (mChips[i] == null)
                        {
                            continue;
                        }

                        Common.StringBuilder name = new Common.StringBuilder();
                        try
                        {
                            name.Append(mChips[i].GetLocalizedName());

                            mSim.TraitChipManager.AddTraitChip(mChips[i], i);
                        }
                        catch (Exception e)
                        {
                            Common.Exception(mSim, null, name, e);
                        }
                    }
                }

                sChangingWorldsSuppression.Pop();

                if ((mChangedHousehold != null) && (mChangedCallback != null))
                {
                    mChangedHousehold.HouseholdSimsChanged = mChangedCallback;
                }
            }
示例#13
0
    // Update is called once per frame
    void Update()
    {
        //Check health
        if (health <= 0 && !isDead)
        {
            isDead = true;
            Die();
        }

        //Set can act
        if (turns <= 0 && attacks <= 0)
        {
            canAct = false;
        }
        else
        {
            canAct = true;
        }

        //Moral De-/Buffs
        switch (moral)
        {
        //Huge debuff
        case -3:
            buffs.AddBuff(Buff.HugeMoralDebuff);
            buffs.RemoveBuff(Buff.SmallMoralBuff);
            buffs.RemoveBuff(Buff.HugeMoralBuff);
            buffs.RemoveBuff(Buff.SmallMoralDebuff);
            break;

        //Small debuff
        case -2:
            buffs.AddBuff(Buff.SmallMoralDebuff);
            buffs.RemoveBuff(Buff.SmallMoralBuff);
            buffs.RemoveBuff(Buff.HugeMoralBuff);
            buffs.RemoveBuff(Buff.HugeMoralDebuff);
            break;

        //Small buff
        case 2:
            buffs.AddBuff(Buff.SmallMoralBuff);
            buffs.RemoveBuff(Buff.SmallMoralDebuff);
            buffs.RemoveBuff(Buff.HugeMoralBuff);
            buffs.RemoveBuff(Buff.HugeMoralDebuff);
            break;

        //Huge buff
        case 3:
            buffs.AddBuff(Buff.HugeMoralBuff);
            buffs.RemoveBuff(Buff.SmallMoralDebuff);
            buffs.RemoveBuff(Buff.SmallMoralBuff);
            buffs.RemoveBuff(Buff.HugeMoralDebuff);
            break;

        //Nothing happens
        default:
            buffs.RemoveBuff(Buff.SmallMoralBuff);
            buffs.RemoveBuff(Buff.HugeMoralBuff);
            buffs.RemoveBuff(Buff.SmallMoralDebuff);
            buffs.RemoveBuff(Buff.HugeMoralDebuff);
            break;
        }
    }
示例#14
0
 public void AddBuff(int buffId, int blevel, double dura)
 {
     BuffManager.AddBuff(buffId, blevel, dura);
 }
示例#15
0
    // Update is called once per frame
    void Update()
    {
        float home = Input.GetAxis("ControllerSelect");

        if (home > 0.1f)
        {
            Destroy(GameObject.FindGameObjectWithTag("PlayerRoot"));
            Destroy(GameObject.FindGameObjectWithTag("MainCamera"));
            Destroy(GameObject.FindGameObjectWithTag("HUDCanvas"));
            Destroy(GameObject.FindGameObjectWithTag("JSONManager"));
            UnityEngine.SceneManagement.SceneManager.LoadScene("testscene");
            return;
        }

        if (!ig)
        {
            ig = ctm.weaponHand.transform.GetComponentInChildren <IntakeGenerator>();
        }

        AnimatorStateInfo animState = anim.GetCurrentAnimatorStateInfo(0);

        var camera  = Camera.main;
        var forward = camera.transform.forward;
        var right   = camera.transform.right;

        forward.y = 0f;
        right.y   = 0f;
        forward.Normalize();
        right.Normalize();

        //Character Movement
        //getting input from controller left stick
        inputH = Input.GetAxis("LeftStickHorizontal");
        inputV = Input.GetAxis("LeftStickVertical");
        Vector2 input = new Vector2(inputH, inputV);

        if (input.magnitude < 0.1f)
        {
            inputH = inputV = 0;
        }
        attacc = Input.GetButtonDown("Fire3");//get x button press
        //attackPressTimer -= Time.deltaTime;
        //if (attacc)
        //    attackPressTimer = 1;
        //if (attackPressTimer < 0)
        //    attacc = false;
        //else
        //    attacc = true;

        rollyPolly = Input.GetButtonDown("Fire2"); // get b button press

        if (attacc)
        {
            if (attaccPhase < 3)
            {
                attaccPhase++;
            }
            else
            {
                attaccPhase = 1;
            }
        }


        //animator setting values
        anim.SetFloat("inputH", inputH);
        anim.SetFloat("inputV", inputV);
        anim.SetBool("attacc", attacc);
        anim.SetInteger("attaccPhase", attaccPhase);
        anim.SetBool("rollyPolly", rollyPolly);

        //print(anim.GetCurrentAnimatorStateInfo(0).tagHash);

        //invuln on roll
        if (animState.tagHash == -1061482972)
        {
            BuffManager.Invulnerability invuln = new BuffManager.Invulnerability();
            invuln.startDuration = 0.1f;
            bm.AddBuff(invuln);
        }

        //enable the swords intake (do damage)
        if (animState.tagHash == 1080829965)
        {
            ig.active = true;
        }
        else
        {
            ig.active = false;
        }


        Vector3 desiredMoveDir = -forward * inputV + right * inputH;

        if (desiredMoveDir.magnitude >= 0.3f)
        {
            transform.forward = desiredMoveDir.normalized;
        }

        transform.position += (desiredMoveDir * player_Speed * Time.deltaTime);

        //rbody movement
        // rbody.velocity = new Vector3(inputH *player_Speed * Time.deltaTime, 0.0f, inputV * -player_Speed * Time.deltaTime);
        //rotate char
        //transform.Rotate(0, Input.GetAxis("RightJoystickHorizontal") * DegreesPerSecond, 0);
        //lastAnim = animState;
    }