コード例 #1
0
ファイル: Player.cs プロジェクト: jstine35/rpgcraft
    void SetRenderInfo()
    {
        if (m_entityRender)
        {
            for (int i = 0; i < 8; ++i)
            {
                int yOffset = (int)m_characterClass * 16;

                m_entityRender.SetFrameInfo(frameGroups[i / 2], i * 16, yOffset, 16, 16);
            }

            // now link frames together
            m_entityRender.LinkNextFrame(frameGroups[0], Up_Cycle1, Up_Cycle2);
            m_entityRender.LinkNextFrame(frameGroups[0], Up_Cycle2, Up_Cycle1);

            m_entityRender.LinkNextFrame(frameGroups[3], Right_Cycle1, Right_Cycle2);
            m_entityRender.LinkNextFrame(frameGroups[3], Right_Cycle2, Right_Cycle1);

            m_entityRender.LinkNextFrame(frameGroups[1], Down_Cycle1, Down_Cycle2);
            m_entityRender.LinkNextFrame(frameGroups[1], Down_Cycle2, Down_Cycle1);

            m_entityRender.LinkNextFrame(frameGroups[2], Left_Cycle1, Left_Cycle2);
            m_entityRender.LinkNextFrame(frameGroups[2], Left_Cycle2, Left_Cycle1);

            m_entityRender.SetGlobalFrameDelay(0.2f);

            m_entityRender.SetCurrentGroup(frameGroups[0]);
        }
    }
コード例 #2
0
    protected override void OnStart()
    {
        base.OnStart();

        EntityRender tickingRender = GetTickingRenderer();

        if (tickingRender != null)
        {
            tickingRender.SetFrameInfo("Main", 0, 0, 32, 32);
            tickingRender.SetCurrentGroup("Main");
        }

        EntityRender explosionRender = GetExplodeRenderer();

        if (explosionRender != null)
        {
            for (int i = 0; i < 12; i++)
            {
                explosionRender.SetFrameInfo("Explode", i * 96, 0, 96, 96);
            }

            for (int i = 0; i < 11; i++)
            {
                explosionRender.LinkNextFrame("Explode", i, i + 1);
            }

            explosionRender.SetGlobalFrameDelay(0.15f);
        }

        StartCoroutine(WaitAndExplode());
    }
コード例 #3
0
    protected override void OnStart()
    {
        base.OnStart();

        if (m_er)
        {
            for (int j = 0; j < 4; ++j)
            {
                for (int i = 0; i < 3; ++i)
                {
                    m_er.SetFrameInfo(frameGroups[j], i * 16, j * 16, 16, 16);
                }
            }

            // now link frames together
            m_er.LinkNextFrame(frameGroups[0], Up_Cycle1, Up_Cycle2);
            m_er.LinkNextFrame(frameGroups[0], Up_Cycle2, Up_Cycle3);
            m_er.LinkNextFrame(frameGroups[0], Up_Cycle3, Up_Cycle1);

            m_er.LinkNextFrame(frameGroups[1], Right_Cycle1, Right_Cycle2);
            m_er.LinkNextFrame(frameGroups[1], Right_Cycle2, Right_Cycle3);
            m_er.LinkNextFrame(frameGroups[1], Right_Cycle3, Right_Cycle1);

            m_er.LinkNextFrame(frameGroups[2], Down_Cycle1, Down_Cycle2);
            m_er.LinkNextFrame(frameGroups[2], Down_Cycle2, Down_Cycle3);
            m_er.LinkNextFrame(frameGroups[2], Down_Cycle3, Down_Cycle1);

            m_er.LinkNextFrame(frameGroups[3], Left_Cycle1, Left_Cycle2);
            m_er.LinkNextFrame(frameGroups[3], Left_Cycle2, Left_Cycle3);
            m_er.LinkNextFrame(frameGroups[3], Left_Cycle3, Left_Cycle1);

            m_er.SetGlobalFrameDelay(0.2f);

            m_er.SetCurrentGroup(frameGroups[RandomManager.Next(0, frameGroups.Length)]);
        }
    }
コード例 #4
0
    public IEnumerator Explode()
    {
        gameObject.transform.localScale *= m_explosionRadius;

        // Find all entities near the bomb within a certain radius
        foreach (var entity in this.EntitiesWithinRadius(m_explosionRadius))
        {
            // TODO: Shameless copied from SwordAttack - Need to be merged into generic code
            Enemy enemy = entity as Enemy;
            if (enemy && (!m_singleHitPerEnemy || !m_hitEntities.ContainsKey(enemy)))
            {
                HealthComponent healthComponent = enemy.HealthComponent;
                if (healthComponent.CanReceiveDamage())
                {
                    // simple damage formula for now
                    int damage = GameManager.Instance.MainPlayer.Experience.Level;

                    // check if critical hit !
                    if (RandomManager.Probability(0.10f))
                    {
                        damage *= 3;
                    }

                    healthComponent.ReceiveDamage(damage);
                    m_hitEntities.Add(enemy, true);

                    Vector2 relativeDir = enemy.transform.position - this.transform.position;
                    enemy.KnockBack(relativeDir.normalized, 3f, 0.05f);
                }
            }
        }

        EntityRender tickingRenderer = GetTickingRenderer();

        tickingRenderer.enabled = false;

        EntityRender explodeRenderer = GetExplodeRenderer();

        explodeRenderer.SetCurrentGroup("Explode");

        AudioManager.PlaySfx(m_explodeSfx);
        yield return(new WaitForSeconds(m_explodeSfx.length));
    }
コード例 #5
0
ファイル: Player.cs プロジェクト: jstine35/rpgcraft
    private GameObject SpawnGameObjectAt(Vector2 origin, GameObject prefab)
    {
        if (prefab == null)
        {
            UnityEngine.Debug.Log("Can't SpawnAttack since m_attackPrefab is null");
            return(null);
        }

        GameObject obj = Instantiate(prefab);

        if (obj == null)
        {
            return(null);
        }

        obj.transform.position = origin;

        EntityRender entityRender = obj.GetComponent <EntityRender>();

        entityRender.SetCurrentGroup("Main");

        return(obj);
    }