Beispiel #1
0
    void Awake()
    {
        puppet = transform.Find("puppet").gameObject;
        zzz    = transform.Find("ZZZ").gameObject;

        nmb          = GetComponent <NovaMovingBlock>();
        anim         = puppet.GetComponent <AlexAnimationScript>();
        nmb.enabled  = false;
        anim.enabled = false;

        zzz.GetComponent <ParticleSystem>().Play();
        puppet.GetComponent <MeshRenderer>().material.mainTextureOffset = new Vector2(0.8f, 0f);
    }
Beispiel #2
0
    // Refactor this so that GameObject is an entity of some type and does its own thing
    public void ApplyToGameObject(GameObject go)
    {
        if (this.type == FrEdLibrary.Type.Buffalo)
        {
            GoomaScript buffalo = go.GetComponent <GoomaScript>();
            buffalo.speed          = this.speed;
            buffalo.checkForFloors = this.checkFloor;
            buffalo.move           = buffalo.speed != 0.0f;
            if (!buffalo.move)
            {
                buffalo.checkForFloors = false;
                this.checkFloor        = false;
            }
        }

        if (this.type == FrEdLibrary.Type.MovingSpikePlatform)
        {
            NovaMovingBlock block = go.GetComponent <NovaMovingBlock>();
            //block.InitFromEditor(this.nodePos, this.speed, this.easing);
        }

        //apply stats for decoration
        if (this.type == FrEdLibrary.Type.Decoration)
        {
            if (this.aniId != -1)
            {
                FrEdAniScript aniScript  = go.AddComponent <FrEdAniScript>();
                FrEdInfo      infoScript = go.GetComponent <FrEdInfo>();
                aniScript.go         = infoScript.puppet;
                aniScript.meshFilter = aniScript.go.GetComponent <MeshFilter>();
                aniScript.aniId      = this.aniId;
            }
        }

        //apply stats for particle system
        if (this.type == FrEdLibrary.Type.Particles)
        {
            ParticleSystem ps = go.GetComponentInChildren <ParticleSystem>();
            var            em = ps.emission;
            em.rateOverTime = this.emissionPerSecond;

            var ma = ps.main;
            var sz = ma.startSize;
            sz.mode        = ParticleSystemCurveMode.TwoConstants;
            sz.constantMin = this.startSizeMin;
            sz.constantMax = this.startSizeMax;
            ma.startSize   = sz;
            //Debug.Log("setting size: " + this.startSizeMin + ", " + this.startSizeMax);

            var sp = ma.startSpeed;
            sp.constantMin = this.startSpeedMin;
            sp.constantMax = this.startSpeedMax;
            sp.mode        = ParticleSystemCurveMode.TwoConstants;
            ma.startSpeed  = sp;

            var lf = ma.startLifetime;
            lf.constantMin   = this.startLifespanMin;
            lf.constantMax   = this.startLifespanMax;
            lf.mode          = ParticleSystemCurveMode.TwoConstants;
            ma.startLifetime = lf;

            var sh = ps.shape;
            sh.shapeType = this.shape;
            sh.scale     = this.shapeScale;

            var cl = ps.colorOverLifetime;
            cl.enabled = true;
            Gradient grad = new Gradient();
            grad.SetKeys(
                new GradientColorKey[] {
                new GradientColorKey(this.color1, 0.0f),
                new GradientColorKey(this.color2, 1.0f)
            },
                new GradientAlphaKey[] {
                new GradientAlphaKey(this.alpha1, 0.0f),
                new GradientAlphaKey(this.alpha2, 0.25f),
                new GradientAlphaKey(this.alpha3, 0.5f),
                new GradientAlphaKey(this.alpha4, 0.75f),
                new GradientAlphaKey(this.alpha5, 1.0f)
            }
                );
            cl.color = grad;

            var rt = ps.rotationOverLifetime;
            rt.enabled      = true;
            rt.separateAxes = true;
            var rtz = rt.z;
            rtz.constantMin = this.rotationMin;
            rtz.constantMax = this.rotationMax;
            rtz.mode        = ParticleSystemCurveMode.TwoConstants;
            rt.z            = rtz;

            ParticleSystemRenderer psr = go.GetComponentInChildren <ParticleSystemRenderer>();
            psr.mesh = FrEdLibrary.instance.GetMesh(this.mesh);
        }

        //apply stats for camera trigger
        if (this.type == FrEdLibrary.Type.CameraTrigger)
        {
            SetStateCameraState script = go.GetComponentInChildren <SetStateCameraState>();
            script.state       = this.cameraState;
            script.pos.x       = this.nodePos.x;
            script.pos.y       = this.nodePos.y;
            script.scrollSpeed = this.speed;
            script.trackXOrY   = this.track;
            script.minX        = this.min.x;
            script.maxX        = this.max.x;
            script.minY        = this.min.y;
            script.maxY        = this.max.y;

            script.setState       = true;
            script.setPos         = true;
            script.setScrollSpeed = true;
            script.setTrackXOrY   = true;
            script.setMinX        = true;
            script.setMaxX        = true;
            script.setMinY        = true;
            script.setMaxY        = true;
        }

        //apply stats for firestick
        if (this.type == FrEdLibrary.Type.Firestick)
        {
            Rotate2Script script = go.GetComponentInChildren <Rotate2Script>();
            script.speed.z = this.speed;
        }

        //apply stats for laser
        if (this.type == FrEdLibrary.Type.Laser)
        {
            Rotate2Script script = go.GetComponent <Rotate2Script>();
            script.speed.z = this.speed;
        }

        //apply stats for quadlaser
        if (this.type == FrEdLibrary.Type.QuadLaser)
        {
            Rotate2Script script = go.GetComponent <Rotate2Script>();
            script.speed.z = this.speed;
        }

        //apply stats for frog
        if (this.type == FrEdLibrary.Type.Frog)
        {
            FrEdFrogScript frogScript = go.GetComponent <FrEdFrogScript>();
            frogScript.ammoId = this.ammoId;
            frogScript.delay  = this.firingDelay;
        }

        //set speed & lifespan for ninja stars
        if (this.type == FrEdLibrary.Type.NinjaStar)
        {
            //Debug.Log("APPLYING NINJA STAR STATS");
            FreshBulletScript freshBulletScript = go.GetComponent <FreshBulletScript>();
            freshBulletScript.speed    = this.speed;
            freshBulletScript.lifespan = this.lifespan;
        }

        //set speed & lifespan for missiles
        if (this.type == FrEdLibrary.Type.HomingMissile ||
            this.type == FrEdLibrary.Type.SpikyHomingMissile)
        {
            FreshHomingMissileScript homingMissileScript = go.GetComponent <FreshHomingMissileScript>();
            homingMissileScript.slowMissile       = false;
            homingMissileScript.speed             = this.speed;
            homingMissileScript.lifespanInSeconds = this.lifespan;
            homingMissileScript.turnSpeed         = this.turningSpeed;
            homingMissileScript.lockToThisZ       = this.zPos;
        }

        //set tilt
        if (this.type != FrEdLibrary.Type.Block)
        {
            go.transform.SetAngZ(this.tilt);
        }

        //set scale
        go.transform.SetScaleX(this.scale.x);
        go.transform.SetScaleY(this.scale.y);

        //Destination level
        if (this.type == FrEdLibrary.Type.Portal)
        {
            PortalScript portalScript = go.GetComponent <PortalScript>();
            if (portalScript != null)
            {
                bool   isButtLevel = !string.IsNullOrEmpty(this.destinationButt);
                string level       = (isButtLevel)? this.destinationButt : this.destinationLevel;
                portalScript.Initialize(level, isButtLevel, this.noSound);
            }
        }

        //set generic info stats
        FrEdInfo info = go.GetComponent <FrEdInfo>();

        if (info != null)
        {
            info.int1 = this.int1;
            info.set  = true;
        }
    }