Exemplo n.º 1
0
    protected override void OnUpdate()
    {
        foreach (var e in GetEntities <Group>())
        {
            var _bullet = e._Bullet;
            if (_bullet.isActive)
            {
                var _transform = e._Transform;

                _bullet.timer.Update();

                if (Physics.Raycast(_transform.position, _transform.forward, out _bullet.hit, _bullet.speed * Time.deltaTime, _bullet.layerMask))
                {
                    var hitInfo         = _bullet.hit;
                    var hitTag          = hitInfo.collider.tag;
                    var _attackListener = hitInfo.collider.gameObject.GetComponentInParent <C_AttackListener>();

                    if (_attackListener != null)
                    {
                        if (_attackListener.isActive)
                        {
                            // Add impact effect
                            if (Aspect.IsAvatarTags(hitTag))
                            {
                                var attack = _bullet.attack;
                                // Modify demage by different body part
                                attack.demage = (int)(_bullet.attack.demage * AvatarTagsData.demageRate[hitTag]);

                                // Set if head shot
                                attack.headShot = AvatarTagsData.IsHead(hitTag);

                                // Add blood effect
                                Effect.AddEffect(_attackListener.hitEffect, hitInfo);

                                // Add attack info in attackListener component
                                if (_bullet.isLocal)
                                {
                                    _attackListener.attackList.Add(_bullet.attack);
                                }
                            }
                        }
                    }
                    else
                    {
                        Effect.AddEffect(_bullet.impactEffect, hitInfo);
                        Sound.PlayOneShot(_bullet.audioSource, _bullet.sounds);
                    }
                    this.CloseBullet(_bullet, _transform);
                }
                // -------------------------------------------
                _transform.Translate(Vector3.forward * _bullet.speed * Time.deltaTime);
                if (!_bullet.timer.isRunning)
                {
                    this.CloseBullet(_bullet, _transform);
                }
            }
        }
    }
Exemplo n.º 2
0
 public void OnButtonClick()
 {
     ItemBar.NBT nowNBT = ItemBar.nowSelectNbt;
     if (nowNBT.nbtt == ItemBar.NBTType.Effect)
     {
         Effect.AddEffect(ItemBar.nowSelectNbt.effectNBT.et, ItemBar.nowSelectNbt.effectNBT.el);
         PlayerParticle.AddEffect(ItemBar.nowSelectNbt.effectNBT.color);
         ItemBar.nowSelectNbt = new ItemBar.NBT()
         {
             canUse = false
         };
     }
     ItemBar.UseItem();
     bt.enabled      = false;
     btImage.enabled = false;
     btText.enabled  = false;
 }
Exemplo n.º 3
0
    public EffectBuilder AddArmour(float percentage)
    {
        effect.AddEffect("ARMOUR", percentage);

        return(this);
    }
    // Update is called once per frame
    void Update()
    {
        CheckInput();

        if(isStatePaused || isStateSelectTarget)
            return;

        ellapsedTime += Time.deltaTime;

        //if a unit is not acting, advance ATguages until one does and set next to act
        if (!isUnitActing)
        {
            AdvanceACTGuagesTurnBased();
        }

        if(isUnitActing)
        {
            actingUnit.sheet.action_Next.UpdateAction();

            if(actingUnit.sheet.action_Next.isTriggerEffect)
            {
                //purely debug block
                DetermineTargets(actingUnit.sheet.action_Next.actionComponents[0].targetType);
                foreach(Character unit in targetedUnits)
                {
                    Debug.Log(actingUnit.sheet.characterName + " uses " + actingUnit.sheet.action_Next.actionName + " on " + unit.sheet.characterName);
                }
                //end debug output

                foreach(ActionComponent actionComponent in actingUnit.sheet.action_Next.actionComponents)
                {
                    isAutoHit = false;  //certain targeting will set this true to skip roll to hit
                    DetermineTargets(actionComponent.targetType);
                    hitUnits = new List<Character>();
                    foreach(Character targetUnit in targetedUnits)
                    {
                        bool isHit = false;
                        if(isAutoHit)
                        {
                            isHit = true;
                        }
                        else
                        {
                            isHit = RollToHit(actionComponent.baseToHit, actionComponent.hitType, targetUnit);
                        }
                        if(isHit)
                        {
                            hitUnits.Add(targetUnit);
                            //apply effect
                            appliedEffect = new Effect(actionComponent,actingUnit,targetUnit);
                            appliedEffect.AddEffect();
                        }
                        else
                        {
                            //missed
                        }
                    }
                }

                CalculateActOrder();
                actingUnit.sheet.action_Next.isTriggerEffect = false;
                actingUnit.sheet.action_Next.isEffectResolved = true;
            }
            if (actingUnit.sheet.action_Next.isActionFinished)
            {
                UpdateEffects(); //tick all effects
                RegenShields();
                isUnitActing = false;
            }

        }
    }