Esempio n. 1
0
        private void lstAttackContexts_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (lstAttack.SelectedIndex <= -1 || lstAttackContexts.SelectedIndex <= -1)
            {
                gbAttackOriginContext.Enabled = false;
                gbAttackTargetContext.Enabled = false;
                gbAnimations.Enabled          = false;
                return;
            }

            gbAttackOriginContext.Enabled = true;
            gbAttackTargetContext.Enabled = true;
            gbAnimations.Enabled          = true;

            AttackContext ActiveContext = _ListAttack[lstAttack.SelectedIndex].Animations[lstAttackContexts.SelectedIndex];

            txtAttackContextName.Text        = ActiveContext.ContextName;
            txtAttackContextParserValue.Text = ActiveContext.ParserValue;

            cbAttackOriginType.SelectedIndex = (int)ActiveContext.AttackOriginType;
            cbAttackTargetType.SelectedIndex = (int)ActiveContext.AttackTargetType;

            txtAttackOriginCustomType.Text = ActiveContext.AttackOriginCustomType;
            txtAttackTargetCustomType.Text = ActiveContext.AttackTargetCustomType;
            txtAttackContextWeight.Value   = ActiveContext.Weight;

            lstAttackAnimations.SelectedIndex = 0;
        }
Esempio n. 2
0
    public void FireBullet(APCharacterController launcher, AttackContext context)
    {
        if (CanFireBullet())
        {
            if (!m_infiniteAmmo)
            {
                m_ammoBox.AddAmmo(-1);
            }

            // make sure move horizontal direction is valid
            bool    bFaceRight = launcher.GetMotor().m_faceRight;
            float   fAngle     = Mathf.Deg2Rad * context.m_bulletDirection;
            Vector2 v2MoveDir  = new Vector2(Mathf.Cos(fAngle), -Mathf.Sin(fAngle));
            if (bFaceRight && v2MoveDir.x < 0f || !bFaceRight && v2MoveDir.x > 0f)
            {
                v2MoveDir.x = -v2MoveDir.x;
            }

            // spawn and launch bullet (add player velocity before spawn)
            Vector2 pointPos = launcher.transform.TransformPoint(context.m_bulletStartPosition);
            pointPos = pointPos + (Time.deltaTime * launcher.GetMotor().m_velocity);

            float      bulletSign = m_bullet.m_faceRight ? 1f : -1f;
            Quaternion rot        = Quaternion.Euler(0f, 0f, bFaceRight != m_bullet.m_faceRight ? bulletSign * context.m_bulletDirection : -bulletSign * context.m_bulletDirection);
            APBullet   newBullet  = (APBullet)UnityEngine.Object.Instantiate(m_bullet, pointPos, rot);
            newBullet.enabled = true;

            // init bullet
            v2MoveDir = launcher.transform.TransformDirection(v2MoveDir);
            newBullet.Setup(launcher, v2MoveDir);

            // launch listeners
            launcher.EventListeners.ForEach(e => e.OnAttackBulletFired(this, newBullet));
        }
    }
Esempio n. 3
0
 public AttackContext GetCurrentContext(APCharacterController character)
 {
     if (m_useAimAnimations)
     {
         // Check inputs and update animation according to this
         AttackContext ctx    = m_contextAimFront;
         bool          bFront = Mathf.Abs(character.m_inputs.m_axisX.GetValue()) > 0f;
         bool          bUp    = character.m_inputs.m_axisY.GetValue() > 0f;
         bool          bDown  = character.m_inputs.m_axisY.GetValue() < 0f;
         if (bFront)
         {
             if (bUp)
             {
                 ctx = m_contextAimFrontUp;
             }
             else if (bDown)
             {
                 ctx = m_contextAimFrontDown;
             }
         }
         else if (bUp)
         {
             ctx = m_contextAimUp;
         }
         else if (bDown)
         {
             ctx = m_contextAimDown;
         }
         return(ctx);
     }
     else
     {
         bool bCrouched = character.IsCrouched();
         if (bCrouched)
         {
             return(m_contextCrouched);
         }
         else if (character.IsOnGround())
         {
             if (!character.IsRunning())
             {
                 return(m_contextStand);
             }
             else
             {
                 return(m_contextRun);
             }
         }
         else
         {
             return(m_contextInAir);
         }
     }
 }
Esempio n. 4
0
        private void txtAttackTargetCustomType_TextChanged(object sender, EventArgs e)
        {
            if (lstAttack.SelectedIndex <= -1 || lstAttackContexts.SelectedIndex <= -1)
            {
                return;
            }

            AttackContext ActiveContext = _ListAttack[lstAttack.SelectedIndex].Animations[lstAttackContexts.SelectedIndex];

            ActiveContext.AttackTargetCustomType = txtAttackTargetCustomType.Text;
        }
Esempio n. 5
0
        private void txtAttackContextWeight_ValueChanged(object sender, EventArgs e)
        {
            if (lstAttack.SelectedIndex <= -1 || lstAttackContexts.SelectedIndex <= -1)
            {
                return;
            }

            AttackContext ActiveContext = _ListAttack[lstAttack.SelectedIndex].Animations[lstAttackContexts.SelectedIndex];

            ActiveContext.Weight = (int)txtAttackContextWeight.Value;
        }
Esempio n. 6
0
        private void txtAttackContextParserValue_TextChanged(object sender, EventArgs e)
        {
            if (lstAttack.SelectedIndex <= -1 || lstAttackContexts.SelectedIndex <= -1)
            {
                return;
            }

            AttackContext ActiveContext = _ListAttack[lstAttack.SelectedIndex].Animations[lstAttackContexts.SelectedIndex];

            ActiveContext.ParserValue = txtAttackContextParserValue.Text;
        }
Esempio n. 7
0
        private void cbAttackTargetType_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (lstAttack.SelectedIndex <= -1 || lstAttackContexts.SelectedIndex <= -1)
            {
                return;
            }

            AttackContext ActiveContext = _ListAttack[lstAttack.SelectedIndex].Animations[lstAttackContexts.SelectedIndex];

            ActiveContext.AttackTargetType     = (ContextTypes)cbAttackTargetType.SelectedIndex;
            txtAttackTargetCustomType.ReadOnly = ActiveContext.AttackTargetType == ContextTypes.Custom;
        }
Esempio n. 8
0
        public override void Notify(Entity activeStats, ActionContext actionContext)
        {
            AttackContext attackContext = actionContext as AttackContext;

            if (attackContext == null)
            {
                return;
            }
            if (attackContext.ActiveGem != m_ActiveGem)
            {
                return;
            }
            Stat destination = activeStats.GetStat(m_Destination.Identifier);

            destination += activeStats.GetStat(ModType.Identifier);
        }
        public override bool Notify(Entity activeStats, ActionContext actionContext)
        {
            AttackContext attackContext = actionContext as AttackContext;

            if (attackContext == null || attackContext.ActiveGem == null)
            {
                return(false);
            }

            string[] attackTags = attackContext.ActiveGem.Tags.ToArray();
            foreach (TagIdentifier tagIdentifier in m_SupportedAttackTags)
            {
                if (attackTags.Contains(tagIdentifier.Identifier))
                {
                    return(true);
                }
            }

            return(false);
        }
Esempio n. 10
0
        private void btnAddAttackContext_Click(object sender, EventArgs e)
        {
            if (lstAttack.SelectedIndex <= -1)
            {
                return;
            }

            Attack        ActiveAttack     = _ListAttack[lstAttack.SelectedIndex];
            AttackContext NewAttackContext = new AttackContext();

            NewAttackContext.Animations.Start        = new Core.Units.AnimationInfo(Name + "/Start");
            NewAttackContext.Animations.EndHit       = new Core.Units.AnimationInfo(Name + "/End Hit");
            NewAttackContext.Animations.EndMiss      = new Core.Units.AnimationInfo(Name + "/End Miss");
            NewAttackContext.Animations.EndDestroyed = new Core.Units.AnimationInfo(Name + "/End Destroyed");
            NewAttackContext.Animations.EndBlocked   = new Core.Units.AnimationInfo(Name + "/End Blocked");
            NewAttackContext.Animations.EndParried   = new Core.Units.AnimationInfo(Name + "/End Parried");
            NewAttackContext.Animations.EndShootDown = new Core.Units.AnimationInfo(Name + "/End Shoot Down");
            NewAttackContext.Animations.EndNegated   = new Core.Units.AnimationInfo(Name + "/End Negated");
            ActiveAttack.Animations.Add(NewAttackContext);
            lstAttackContexts.Items.Add("Any");
        }
Esempio n. 11
0
    public void FireBullet(APCharacterController launcher, ContextId contextId)
    {
        if ((m_ammo > 0 || m_infiniteAmmo) && (m_bullet != null))
        {
            if (!m_infiniteAmmo)
            {
                m_ammo--;
            }

            AttackContext curContext = m_contextStand;
            switch (contextId)
            {
            case ContextId.eRun: curContext = m_contextRun; break;

            case ContextId.eInAir: curContext = m_contextInAir; break;

            case ContextId.eCrouched: curContext = m_contextCrouched; break;
            }

            // make sure move horizontal direction is valid
            float   fAngle    = Mathf.Deg2Rad * curContext.m_bulletDirection;
            Vector2 v2MoveDir = new Vector2(Mathf.Cos(fAngle), -Mathf.Sin(fAngle));
            if (launcher.GetMotor().m_faceRight&& v2MoveDir.x < 0f || !launcher.GetMotor().m_faceRight&& v2MoveDir.x > 0f)
            {
                v2MoveDir.x = -v2MoveDir.x;
            }

            // spawn and launch bullet (add player velocity before spawn)
            Vector2 pointPos = launcher.transform.TransformPoint(curContext.m_bulletStartPosition);
            pointPos = pointPos + (Time.deltaTime * launcher.GetMotor().m_velocity);
            APBullet newBullet = (APBullet)UnityEngine.Object.Instantiate(m_bullet, pointPos, Quaternion.identity);

            // init bullet
            v2MoveDir = launcher.transform.TransformDirection(v2MoveDir);
            newBullet.Setup(launcher, pointPos, v2MoveDir);

            // launch listeners
            launcher.EventListeners.ForEach(e => e.OnAttackBulletFired(this, newBullet));
        }
    }
Esempio n. 12
0
    public void RefreshAnimations(APCharacterController character)
    {
        AttackContext ctx = GetCurrentContext(character);

        if (ctx != null && ctx.m_enabled)
        {
            // Handle aim sub context properly
            AttackContextAim ctxAim = ctx as AttackContextAim;
            if (ctxAim != null)
            {
                character.PlayAnim(character.IsRunning() && ctxAim.m_animRun.IsValid() ? ctxAim.m_animRun : ctxAim.m_anim);
            }
            else
            {
                // keep default set of animation if not overrided by each attack
                if (ctx.m_anim.IsValid())
                {
                    character.PlayAnim(ctx.m_anim);
                }
            }
        }
    }
Esempio n. 13
0
 public bool IsValidContext(AttackContext context) => Context == context || Context == AttackContext.NotDefined;