Пример #1
0
    void _Increment(int incr)
    {
        int previousAttackIndex = m_currentAttackIndex;

        m_currentAttackIndex += incr;
        if (m_loop)
        {
            if (m_currentAttackIndex >= m_attacks.Length)
            {
                m_currentAttackIndex = 0;
            }
            else if (m_currentAttackIndex < 0)
            {
                m_currentAttackIndex = m_attacks.Length - 1;
            }
        }
        else
        {
            m_currentAttackIndex = Mathf.Clamp(m_currentAttackIndex, 0, m_attacks.Length - 1);
        }

        if (previousAttackIndex != m_currentAttackIndex)
        {
            _RefreshAttack();

            // We switched to new attack, call listeners
            APAttack newAttack = GetCurrentAttack();
            m_character.EventListeners.ForEach(e => e.OnSelectAttack(newAttack));
        }
    }
Пример #2
0
 void _RefreshAttack()
 {
     if (m_currentAttackIndex < m_attacks.Length)
     {
         m_currentAttack = m_character.GetAttack(m_attacks[m_currentAttackIndex]);
     }
     else
     {
         m_currentAttack = null;
     }
 }
Пример #3
0
    // Drawing
    void OnGUI()
    {
        GUILayout.BeginHorizontal();

        if (m_showLife)
        {
            GUILayout.Box(m_textureLife, m_icon);
            GUILayout.Label(m_lifeCount.ToString(), m_text);
        }

        if (m_showScore)
        {
            GUILayout.Box(m_textureScore, m_icon);
            GUILayout.Label(m_scoreCount.ToString(), m_text);
        }

        if (m_showAmmo)
        {
            // Here we draw all attacks of first switchers if any, then we only highlight selected attack
            if (m_character.m_attacks.m_switchers.Length > 0)
            {
                APAttackSwitcher selector = m_character.m_attacks.m_switchers[0];
                foreach (APAttackTexture attackTexture in m_attackTextures)
                {
                    bool bActive = false;
                    if (string.Compare(attackTexture.m_attackName, selector.GetCurrentAttack().m_name) == 0)
                    {
                        bActive = true;
                    }

                    APAttack charAttack = m_character.GetAttack(attackTexture.m_attackName);
                    if (charAttack != null)
                    {
                        GUI.contentColor = bActive ? Color.white : new Color(1, 1, 1, 0.3f);
                        GUILayout.Box(attackTexture.m_texture, m_icon);
                        GUILayout.Label(charAttack.m_ammoBox ? charAttack.m_ammoBox.GetAmmoString() : "0", m_text);
                        GUI.contentColor = Color.white;
                    }
                }
            }
        }

        GUILayout.EndHorizontal();

        // Handle fade to black
        if (m_fadeToBlack)
        {
            Color color = Color.white;
            color.a   = m_fadeAlpha;
            GUI.color = color;
            GUI.DrawTexture(new Rect(0f, 0f, Screen.width, Screen.height), m_textureFade);
        }
    }
    public void OnSceneGUI()
    {
        APCharacterController oController = (APCharacterController)target;

        // draw all melee attack zones and allow to move them when selecting controller
        if (oController.m_attacks != null && oController.m_attacks.m_enabled)
        {
            foreach (APAttack curAttack in oController.m_attacks.m_attacks)
            {
                foreach (APHitZone curZone in curAttack.m_hitZones)
                {
                    if (curZone.m_active && curZone.gameObject.activeInHierarchy)
                    {
                        Vector3 pointPos = curZone.transform.position;
                        Color   color    = Color.green;
                        color.a       = 0.5f;
                        Handles.color = color;
                        Vector3 newPos = Handles.FreeMoveHandle(pointPos, Quaternion.identity, curZone.m_radius * 2f, Vector3.zero, Handles.SphereHandleCap);
                        if (newPos != pointPos)
                        {
                            Undo.RecordObject(curZone.transform, "Move Hit Zone");
                            curZone.transform.position = newPos;

                            // mark object as dirty
                            EditorUtility.SetDirty(curZone);
                        }
                    }
                }
            }
        }

        // draw all ranged attack spawning bullets and allow to move them when selecting controller
        if (oController.m_attacks != null && oController.m_attacks.m_enabled && m_bShow)
        {
            for (int i = 0; i < oController.m_attacks.m_attacks.Length; i++)
            {
                APAttack curAttack = oController.m_attacks.m_attacks[i];
                DrawStartPos(curAttack.m_contextStand, m_bShowBulletSpawnsStand[i]);
                DrawStartPos(curAttack.m_contextRun, m_bShowBulletSpawnsRun[i]);
                DrawStartPos(curAttack.m_contextInAir, m_bShowBulletSpawnsInAir[i]);
                DrawStartPos(curAttack.m_contextCrouched, m_bShowBulletSpawnsCrouched[i]);

                DrawStartPos(curAttack.m_contextAimFront, m_bShowBulletSpawnsFront[i]);
                DrawStartPos(curAttack.m_contextAimDown, m_bShowBulletSpawnsUp[i]);
                DrawStartPos(curAttack.m_contextAimUp, m_bShowBulletSpawnsDown[i]);
                DrawStartPos(curAttack.m_contextAimFrontUp, m_bShowBulletSpawnsFrontUp[i]);
                DrawStartPos(curAttack.m_contextAimFrontDown, m_bShowBulletSpawnsFrontDown[i]);
            }
        }
    }
Пример #5
0
 public virtual void OnAttackEnd(APAttack attack)
 {
 }
Пример #6
0
 public virtual void OnAttackMeleeHit(APAttack attack, APHitable hitObject)
 {
 }
Пример #7
0
 public virtual void OnAttackBulletFired(APAttack attack, APBullet bullet)
 {
 }
Пример #8
0
 public virtual void OnAttackStart(APAttack attack)
 {
 }
Пример #9
0
 // Called when a select is made to specified attack
 public virtual void OnSelectAttack(APAttack attack)
 {
 }
Пример #10
0
 // Refresh GUI
 public override void OnAttackBulletFired(APAttack attack, APBullet bullet)
 {
     m_ammoCount = attack.m_ammo;
 }