Ejemplo n.º 1
0
    public static SkillsBehaviour attachSkillTo(GameObject go, OSkills oSkill)
    {
        SkillsBehaviour behaviour = null;

        if (oSkill is OSkillAOE)
        {
            behaviour = go.AddComponent <SkillAOEBehaviour>();

            addCommon(go, behaviour, oSkill);

            ((SkillAOEBehaviour)behaviour).effectPrefab = ((OSkillAOE)oSkill).effectPrefab;
            ((SkillAOEBehaviour)behaviour).radius       = ((OSkillAOE)oSkill).radius;
            ((SkillAOEBehaviour)behaviour).spawnAt      = ((OSkillAOE)oSkill).spawnAt;
            ((SkillAOEBehaviour)behaviour).duration     = ((OSkillAOE)oSkill).duration;
            ((SkillAOEBehaviour)behaviour).startSound   = ((OSkillAOE)oSkill).startSound;
            ((SkillAOEBehaviour)behaviour).hitSound     = ((OSkillAOE)oSkill).hitSound;
        }
        else if (oSkill is OSkillBlast)
        {
            behaviour = go.AddComponent <SkillBlastBehaviour>();

            addCommon(go, behaviour, oSkill);


            ((SkillBlastBehaviour)behaviour).blast          = ((OSkillBlast)oSkill).blast;
            ((SkillBlastBehaviour)behaviour).offset         = ((OSkillBlast)oSkill).offset;
            ((SkillBlastBehaviour)behaviour).blastDirection = ((OSkillBlast)oSkill).blastDirection;
            ((SkillBlastBehaviour)behaviour).shootSound     = ((OSkillBlast)oSkill).shootSound;
        }
        else if (oSkill is OSkillCrush)
        {
            behaviour = go.AddComponent <SkillCrushBehaviour>();

            addCommon(go, behaviour, oSkill);

            ((SkillCrushBehaviour)behaviour).effectPrefab = ((OSkillCrush)oSkill).effectPrefab;
            //((SkillCrushBehaviour)behaviour).spawnPoint    =((OSkillCrush)oSkill).spawnPoint    ;
            ((SkillCrushBehaviour)behaviour).crushSpeed    = ((OSkillCrush)oSkill).crushSpeed;
            ((SkillCrushBehaviour)behaviour).crushDuration = ((OSkillCrush)oSkill).crushDuration;
            ((SkillCrushBehaviour)behaviour).startSound    = ((OSkillCrush)oSkill).startSound;


            Transform sp    = ((OSkillCrush)oSkill).spawnPoint;
            Transform sp_go = Object.Instantiate(sp, go.transform.position, go.transform.rotation) as Transform;
            sp_go.localPosition = sp.localPosition;
            sp_go.localRotation = sp.localRotation;
            sp_go.SetParent(go.transform);
            ((SkillCrushBehaviour)behaviour).spawnPoint = sp_go;
        }
        else if (oSkill is OSkillMelee)
        {
            Debug.Log("OSkillMelee not ready");
        }
        else if (oSkill is OSkillProjectile)
        {
            behaviour = go.AddComponent <SkillProjectileBehaviour>();

            addCommon(go, behaviour, oSkill);

            ((SkillProjectileBehaviour)behaviour).bulletPrefab     = ((OSkillProjectile)oSkill).bullet;
            ((SkillProjectileBehaviour)behaviour).bulletSpeed      = ((OSkillProjectile)oSkill).bulletSpeed;
            ((SkillProjectileBehaviour)behaviour).bulletSteerSpeed = ((OSkillProjectile)oSkill).bulletSteerSpeed;
            ((SkillProjectileBehaviour)behaviour).shootSound       = ((OSkillProjectile)oSkill).shootSound;

            ((SkillProjectileBehaviour)behaviour).spawnPoints = new Transform[((OSkillProjectile)oSkill).spawnPoints.Length];
            for (int i = ((OSkillProjectile)oSkill).spawnPoints.Length - 1; i >= 0; i--)
            {
                Transform sp    = ((OSkillProjectile)oSkill).spawnPoints[i];
                Transform sp_go = Object.Instantiate(sp, go.transform.position, go.transform.rotation) as Transform;
                sp_go.localPosition = sp.localPosition;
                sp_go.localRotation = sp.localRotation;
                sp_go.SetParent(go.transform);
                ((SkillProjectileBehaviour)behaviour).spawnPoints[i] = sp_go;
            }
        }

        return(behaviour);
    }