示例#1
0
    public void StartUp(int _spawnSlot)
    {
        spawnSlot           = _spawnSlot;
        transform.position += (Vector3.up * yOffset);

        //Mesh Setup

        int meshCount  = 0;
        int lightCount = 0;

        for (int i = 0; i < 2; i++)
        {
            foreach (Renderer m in gameObject.GetComponentsInChildren <Renderer>())
            {
                if (i == 1)
                {
                    mesh[meshCount] = m;
                }
                meshCount++;
            }

            foreach (Light l in gameObject.GetComponentsInChildren <Light>())
            {
                if (i == 1)
                {
                    lights[lightCount] = l;
                }
                lightCount++;
            }

            if (i == 0)
            {
                mesh = new Renderer[meshCount];

                if (lightCount > 0)
                {
                    lights = new Light[lightCount];
                }
            }

            meshCount  = 0;
            lightCount = 0;
        }

        if (collectSound)
        {
            SND_collect = SCR_main.CreateSound(transform, collectSound, false, true);
        }

        StartFlash();
    }
示例#2
0
    public static SCR_sound[] SetupSoundArray(Transform parentTrans, AudioClip[] fxClips, bool randomPitch, bool distanceOn)
    {
        SCR_sound[] SND = null;

        if (fxClips != null)
        {
            SND = new SCR_sound[fxClips.Length];
            for (int i = 0; i < fxClips.Length; i++)
            {
                SND[i] = SCR_main.CreateSound(parentTrans, fxClips[i], randomPitch, distanceOn);
            }
        }

        return(SND);
    }
示例#3
0
    public void StartUp()
    {
        cType = controlType;

        main = GetComponent <SCR_main>();

        if (highlightSound)
        {
            SND_highlight = SCR_main.CreateSound(transform, highlightSound, false, false);
        }
        if (selectSound)
        {
            SND_select = SCR_main.CreateSound(transform, selectSound, false, false);
        }
    }
示例#4
0
    void Awake()
    {
        int i = 0;

        //Mesh Setup

        int meshCount = 0;

        for (i = 0; i < 2; i++)
        {
            foreach (Renderer m in gameObject.GetComponentsInChildren <Renderer>())
            {
                if (i == 1)
                {
                    mesh[meshCount] = m;
                }
                meshCount++;
            }

            if (i == 0)
            {
                mesh = new Renderer[meshCount];
            }

            meshCount = 0;
        }

        //Player or Enemy

        if (GetComponent <SCR_characterControl>())
        {
            gameObject.tag = "Player";
            isPlayer       = true;
            cc             = GetComponent <SCR_characterControl>();
            SetRotAngle(transform.position + (Vector3.forward * -10f));
            SetRotTarget();
        }
        else
        {
            gameObject.tag = "Enemy";
            isPlayer       = false;
            invulnerable   = true;
            ai             = GetComponent <SCR_enemyAI>();
            StartFlash(1, 4);
            float patrolMult = 0.5f;
            runSpeedArray = new float[2] {
                runSpeed,
                runSpeed *patrolMult
            };
            runAnimSpeedPatrol = (animSpeed[1] * patrolMult);
        }



        //Melee or Ranged

        if (GetComponent <SCR_characterMelee>())
        {
            characterMelee = GetComponent <SCR_characterMelee>();
            characterMelee.StartUp(isPlayer);
            melee = true;
        }
        else
        {
            characterRanged = GetComponent <SCR_characterRanged>();
            melee           = false;
        }

        //Animation Setup

        int animCount = 0;

        for (i = 0; i < 2; i++)
        {
            foreach (AnimationState clip in GetComponent <Animation>())
            {
                if (i == 1)
                {
                    animArray[animCount] = clip.name;
                }
                animCount++;
            }

            if (i == 0)
            {
                animArray = new string[animCount];
                animCount = 0;
            }
        }

        //Set the cross fade speed for each animation
        animBlendSpeed = new float[9] {
            0.15f,
            0.15f,
            0.1f,
            0.15f,
            0.0f,
            0.0f,
            0.0f,
            0.0f,
            0.0f
        };

        //Set the speed for each animation
        for (i = 0; i < animArray.Length; i++)
        {
            if (GetComponent <Animation>()[animArray[i]])
            {
                GetComponent <Animation>()[animArray[i]].speed = animSpeed[i];
            }
        }

        if (rollSound)
        {
            SND_roll = SCR_main.CreateSound(transform, rollSound, false, true);
        }


        if (GetComponent <BoxCollider>())
        {
            hitBoxSize = (GetComponent <BoxCollider>().size.x *transform.localScale.x *0.5f);
        }
        transform.rotation = rotTarget;

        if (isPlayer)
        {
            cc.StartUp();
        }
        else
        {
            ai.StartUp();
        }
    }