public void AddBuff(BuffType type, float time)
    {
        Buff Buff = null;

        switch (type)
        {
        case BuffType.SpeedBuff:
            Buff = new SpeedBuff();
            break;

        case BuffType.JumpBoostBuff:
            Buff = new JumpBoostBuff();
            break;
        }
        if (Buff != null)
        {
            Buff.ApplyBuff(player);
            var buffList = BuffList.Value;
            buffList.Add(Buff);
            BuffList.OnNext(buffList);
            Observable.Timer(TimeSpan.FromSeconds(time)).Subscribe(obComplete =>
            {
                Buff.RemoveBuff();
                RemoveBuffFromList(Buff);
            });
        }
    }
示例#2
0
    IEnumerator SpeedMultiplierDuration(SpeedBuff _ref)
    {
        yield return(new WaitForSeconds(_ref.seconds));

        speedMultipliers.Remove(_ref);
        UpdateSpeedMultipliers();
    }
	public override void activeSkill(Object data)
	{
		SpeedBuff atkbuff = new SpeedBuff ();
		atkbuff.duration = 3600;
		atkbuff.affectValue = (float)(parentController.getVelocity () * 0.05);
		gameCtrl.attachBuffToEntityController (atkbuff, parentController);
	}
示例#4
0
    // Update is called once per frame
    void Update()
    {
        timeConsumed += Time.deltaTime;
        float totalSpeedBuff = 0;

        numOfBuffTimedOut = 0;
        // Update the current speed buff value
        for (int i = 0; i < buffs.Count; i++)
        {
            SpeedBuff sb = buffs[i];
            sb.timeLeft -= Time.deltaTime;
            buffs[i]     = sb;
            if (sb.timeLeft > 0)
            {
                totalSpeedBuff += sb.buffVal;
            }
            else
            {
                numOfBuffTimedOut += 1;
            }
        }
        currentSpeedBuff = Mathf.Clamp(totalSpeedBuff, -speedBuffSaturationPt, speedBuffSaturationPt);
        // 3 is magic value of speed buff remove buffer
        if (numOfBuffTimedOut > 3)
        {
            buffs.RemoveAll((SpeedBuff buff) => {
                if (buff.timeLeft <= 0)
                {
                    return(true);
                }
                return(false);
            });
        }
    }
示例#5
0
        private void InitBuff(BuffTypeEnum typeid, Vector3 pos) // 生成一个buff
        {
            Buff newBuff;

            switch (typeid)
            {
            case BuffTypeEnum.HealthBuff:
                newBuff = new HealthBuff(buffCounter, buffUnusedTime);
                break;

            case BuffTypeEnum.SpeedBuff:
                newBuff = new SpeedBuff(buffCounter, buffDefaultActiveTime, buffUnusedTime);
                break;

            case BuffTypeEnum.ShieldBuff:
                newBuff = new ShieldBuff(buffCounter, buffDefaultActiveCount, buffUnusedTime);
                break;

            case BuffTypeEnum.JumpBuff:
                newBuff = new JumpBuff(buffCounter, buffDefaultActiveTime, buffUnusedTime);
                break;

            default: return;
            }

            buffCounter++;
            buffList.Add(newBuff);
            var obj = Instantiate(buffPrefab);

            obj.GetComponent <BuffBehaviour>().SetBuff(newBuff);
            obj.transform.position = pos;
            buffObjects.Add(newBuff.buffId, obj);
        }
示例#6
0
        public void Create(float speed)
        {
            var       player = new Player(Point.Empty, Mock.Of <Inventory>());
            SpeedBuff obj    = new SpeedBuff(speed);

            obj.Apply(player);
            Assert.Equal(player.SpeedMultiplier, speed);
        }
示例#7
0
    public void AddSpeedMultiplier(float amount, float time)
    {
        SpeedBuff newBuff = new SpeedBuff(amount, time);

        speedMultipliers.Add(newBuff);
        UpdateSpeedMultipliers();
        StartCoroutine(SpeedMultiplierDuration(newBuff));
    }
	public override void activeSkill(Object data)
	{

		NinJaController enemy = data as NinJaController;
		SpeedBuff buff = new SpeedBuff ();
		buff.duration = 10f;
		buff.affectValue = -enemy.getVelocity() * 0.1f;
		gameCtrl.attachBuffToEntityController (buff, enemy);
	}
示例#9
0
    public void HeroWandSkill1(Transform tf, string strJson)
    {
        JsonData   data = JsonMapper.ToObject(strJson);
        Hero       hero = tf.GetComponent <Hero>();
        GameObject go   = Pool.Instance.GetObj(AllPath.Instance.effectPrefabsPath + hero.curSkill.ID, tf.position, tf.rotation, tf);

        go.transform.eulerAngles = new Vector3(-90, 0, 0);
        SpeedBuff efc = go.GetComponent <SpeedBuff>();

        efc.recycleTime = 3 * hero.curSkill.LV;
        efc.ratio       = 1 + 0.2f * hero.curSkill.LV;
    }
示例#10
0
        public override bool ApplyEffect(Vector2 effectPosition)
        {
            List <Unit> units = ColliderManager.instance.ReturnUnitInRadius(effectPosition, Radius);

            for (int i = 0; i < units.Count; i++)
            {
                if (units[i].side == Faction.Player)
                {
                    SpeedBuff buff = units[i].gameObject.AddComponent <SpeedBuff>();
                    buff.BuffSpeed = BuffSpeed;
                    buff.StartEffect(DurationEffect);
                }
            }

            return(base.ApplyEffect(effectPosition));
        }
	public override void activeSkill(Object data)
	{
		if (parentController.side == GameController.Side.leftSide) {
			foreach(NinJaController entity in gameCtrl.leftEntities){
				SpeedBuff atkbuff = new SpeedBuff ();
				atkbuff.duration = 3600;
				atkbuff.affectValue = (float)(entity.getVelocity () * 0.05);
				gameCtrl.attachBuffToEntityController (atkbuff, entity);
			}		
		}else if(parentController.side == GameController.Side.rightSide){
			foreach(NinJaController entity in gameCtrl.rightEntities){
				SpeedBuff atkbuff = new SpeedBuff ();
				atkbuff.duration = 3600;
				atkbuff.affectValue = (float)(entity.getVelocity () * 0.05);
				gameCtrl.attachBuffToEntityController (atkbuff, entity);
			}		
		}

	}
示例#12
0
    public override void Start()
    {
        base.Start();

        //Initialize everything
        currentType = IType.ElementType.NoType;
        toggleCamera(0);
        UIScript   = GameObject.Find("Canvas").GetComponent <UI>();
        wheelBuffs = new Buff[12];
        wheelGems  = new Gem[6];
        moves      = new PlayerAttack[3];

        //Starting quest
        currentQuest = new Quest(lm.npcs[0], IType.QuestType.TalkQuest);
        currentQuest.SetTalkTarget(lm.npcs[0]);
        currentQuest.completionObject = GameObject.Find("DOOR1");

        //Default Buffs
        wheelBuffs[0]  = new StrengthBuff();
        wheelBuffs[1]  = new SpeedBuff();
        wheelBuffs[2]  = new ComboBuff();
        wheelBuffs[3]  = new SplitBuff();
        wheelBuffs[4]  = new RelaxBuff();
        wheelBuffs[5]  = new HealBuff();
        wheelBuffs[6]  = new StrengthBuff();
        wheelBuffs[7]  = new LingerBuff();
        wheelBuffs[8]  = new ComboBuff();
        wheelBuffs[9]  = new SpeedBuff();
        wheelBuffs[10] = new HealBuff();
        wheelBuffs[11] = new SpeedBuff();

        //Default Gems
        wheelGems[0] = new Gem(IType.GemType.Breeze);
        wheelGems[1] = new Gem(IType.GemType.Forest);
        wheelGems[2] = new Gem(IType.GemType.Heat);
        wheelGems[3] = new Gem(IType.GemType.Music);
        wheelGems[4] = new Gem(IType.GemType.Space);
        wheelGems[5] = new Gem(IType.GemType.Water);

        UIScript.SetUpWheel();
    }
    private void OnTriggerEnter2D(Collider2D collision)
    {
        if (collision.CompareTag("Player"))
        {
            HornetController player = collision.GetComponent <HornetController>();
            if (rb.velocity.magnitude > 0.1)
            {
                // Direct hit
                print("Direct hit");
                player.TakeDamage(DamageDirect);
            }
            else
            {
                print("Indirect hit");
            }

            // Slow debuff
            SpeedBuff speedBuff = collision.gameObject.AddComponent <SpeedBuff>();
            speedBuff.BuffName       = "Spider Web";
            speedBuff.Duration       = 30f;
            speedBuff.Unique         = true;
            speedBuff.SpeedMuliplier = 0.5f;
            speedBuff.BeginBuff();

            // Damage over time
            if (dps == null)
            {
                dps                    = collision.gameObject.AddComponent <DamageDPS>();
                dps.BuffName           = "Spider Web";
                dps.Damage             = 1f;
                dps.Delay              = 0f;
                dps.ApplyDamageNTimes  = 30f;
                dps.ApplyEveryNSeconds = .1f;
                //dps.BeginDPS();
            }
        }
    }
示例#14
0
 protected override void LoadSkills()
 {
     skill1 = new ProjectileAttack("Sprites/Menu/Skills/spr_skill_9", 1, "Sprites/Items/Projectiles/spr_rock", 1, "Sprites/Items/Particles/spr_rock_explosion@4", 1, 5);
     skill2 = new SpeedBuff("Sprites/Menu/Skills/spr_skill_2", 2, "Sprites/Items/Particles/spr_stamina@4");
     skill3 = new AreaHeal("Sprites/Menu/Skills/spr_skill_1", 3, "Sprites/Items/Particles/spr_heal@6");
 }
示例#15
0
	// Use this for initialization
	void Start () {
		gameObject.tag = "entity";

		animator = GetComponent<Animator>();
		state = State.Find;
		if (transform.localScale.x > 0) {
			isFacingRight = false;		
		} else {
			isFacingRight = true;		
		}
		_attackCoolDown = attackCoolDown;
		isDead = false;
		health = maxhealth;
		GameObject healthbar = Instantiate (Resources.Load (healthBarResource)) as GameObject;
		healthbar.transform.parent = transform;

		GameObject manabar = Instantiate (Resources.Load (manaBarResource)) as GameObject;
		manabar.transform.parent = transform;


		//test------------------------------
		//magic
		GameObject magic1 = ctrl.initMagic ("prefab/xuanyuanjianzhen");
		MagicController con = magic1.GetComponent<MagicController> () as MagicController;
		//magic1.transform.parent = transform;
		con.setParentController (this,ctrl);
		magicList.Add (con);

		//test for buff
		SpeedBuff spdbuff = new SpeedBuff ();
		spdbuff.affectValue = 3.0f;
		spdbuff.duration = 3.0f;
		ctrl.attachBuffToEntityController (spdbuff, this);

		PassiveSkill_ManTianGuoHai skl1 = new PassiveSkill_ManTianGuoHai ();
		learnPassiveSkill (skl1);
		//------------------------------------

		//trigger passive skill in start phase
		foreach (PassiveSkill skl in passiveSkillList) {
			if(skl.phase == PassiveSkill.Phase.Start)
			{
				skl.activeSkill(null);
			}
		}
	}