Ejemplo n.º 1
0
    // events

    void OnTriggerEnter(Collider otherObj)
    {
        if (otherObj.gameObject.tag == "Dust")
        {
            Vector3 dist    = transform.position - otherObj.attachedRigidbody.transform.position;
            float   distMag = dist.magnitude;
            if (distMag > COLLISION_RADIUS)
            {
                if (heldObject == null && Time.realtimeSinceStartup - holdRequestInitateTime < HOLD_TIME_LENIENCY)
                {
                    heldObject = otherObj.attachedRigidbody;
                }
            }
            else if (heldObject != otherObj.attachedRigidbody)
            {
                this.type = otherObj.gameObject.GetComponent <StarDust>().DustType;
                this.GetComponent <MeshFilter>().mesh = otherObj.gameObject.GetComponent <StarDust>().findMesh(type);
                Destroy(otherObj.gameObject);
            }
        }
        else if (otherObj.gameObject.tag == "PassWall")
        {
            if (type != otherObj.GetComponent <PassWall>().type&& !lockLife)
            {
                lockLife = true;
                life--;
                myo.GetComponent <ThalmicMyo>().Vibrate(VibrationType.Short);
                if (life <= 0)
                {
                    if ((GameObject.Find("Player1").GetComponent <Ship>().Life <= 0))
                    {
                        if (opposingShip.GetComponent <Ship>().Life <= 0)
                        {
                            GameObject.Find("Spawner").GetComponent <UIDriver>().showStateText("Just... Wow.\nPunch The Screen\nTo Play Again");
                        }
                        else
                        {
                            GameObject.Find("Spawner").GetComponent <UIDriver>().showStateText("Player 1 Has Died\nPunch The Screen\nTo Play Again");
                        }
                    }
                    else
                    {
                        if (opposingShip.GetComponent <Ship>().Life <= 0)
                        {
                            GameObject.Find("Spawner").GetComponent <UIDriver>().showStateText("Both Of You Suck.\nPunch The Screen\nTo Play Again");
                        }
                        else
                        {
                            GameObject.Find("Spawner").GetComponent <UIDriver>().showStateText("Player 2 Has Died\nPunch The Screen\nTo Play Again");
                        }
                    }
                    GameObject.Find("Spawner").GetComponent <UIDriver>().showHUD(false);
                }
                else
                {
                    GameObject.Find("Spawner").GetComponent <UIDriver>().showHUD(true);
                }
            }
        }
    }
Ejemplo n.º 2
0
    void SpawnWall(DustTypes passWallType, float zset)
    {
        GameObject passWallInstance = (GameObject)Instantiate(passWall, new Vector3(0, 0, zset), Quaternion.AngleAxis(-90, new Vector3(1, 0, 0)));

        passWalls.Add(passWallInstance);
        PassWall script = passWallInstance.GetComponent <PassWall> ();

        script.Setup(passWallType, velocity.z);
        script.Removed += new PassWall.WallRemoved(wallRemoved);
    }
Ejemplo n.º 3
0
    private DustTypes[] failingTypes(DustTypes passingType)
    {
        switch (passingType)
        {
        case DustTypes.CUBE: return(new DustTypes[] { DustTypes.SPERE, DustTypes.TRIANGLE });

        case DustTypes.SPERE: return(new DustTypes[] { DustTypes.CUBE, DustTypes.TRIANGLE });

        case DustTypes.TRIANGLE: return(new DustTypes[] { DustTypes.SPERE, DustTypes.CUBE });
        }
        return(new DustTypes[] {});
    }
Ejemplo n.º 4
0
 public Mesh findMesh(DustTypes dustType)
 {
     switch (dustType) {
     case DustTypes.CUBE:
         return CUBE;
     case DustTypes.SPERE:
         return SPERE;
     case DustTypes.TRIANGLE:
         return TRIANGLE;
     }
     return null;
 }
Ejemplo n.º 5
0
 private void updatePassWall(GameObject obj)
 {
     if (obj.GetComponent <Nemesis>().passWalls.Count > 0)
     {
         prevPassWall = obj.GetComponent <Nemesis>().passWalls[0].GetComponent <PassWall>().type;
         showGateWarning(true);
     }
     else
     {
         showGateWarning(false);
     }
 }
Ejemplo n.º 6
0
 public Color findMatterial(DustTypes dustType)
 {
     switch (dustType)
     {
         case DustTypes.CUBE:
             return Color.blue;
         case DustTypes.SPERE:
             return Color.green;
         case DustTypes.TRIANGLE:
             return Color.magenta;
     }
     return Color.black;
 }
Ejemplo n.º 7
0
    public void spawnDust(DustTypes type, Vector3 pos)
    {
        GameObject newDust = (GameObject)Instantiate(startDust, pos, Quaternion.identity);

        dust.Add(newDust);

        StarDust script = newDust.GetComponent <StarDust> ();

        script.Removed += new StarDust.DustRemoved(dustRemoved);
        script.DustType = type;
        script.Velocity = velocity;
        script.spin();
    }
Ejemplo n.º 8
0
 public Material findMatterial(DustTypes dustType)
 {
     switch (dustType)
     {
         case DustTypes.CUBE:
             return cubeMat;
         case DustTypes.SPERE:
             return sphereMat;
         case DustTypes.TRIANGLE:
             return triangleMat;
     }
     return null;
 }
Ejemplo n.º 9
0
    public Color findMatterial(DustTypes dustType)
    {
        switch (dustType)
        {
        case DustTypes.CUBE:
            return(Color.blue);

        case DustTypes.SPERE:
            return(Color.green);

        case DustTypes.TRIANGLE:
            return(Color.magenta);
        }
        return(Color.black);
    }
Ejemplo n.º 10
0
    public Mesh findMesh(DustTypes dustType)
    {
        switch (dustType)
        {
        case DustTypes.CUBE:
            return(CUBE);

        case DustTypes.SPERE:
            return(SPERE);

        case DustTypes.TRIANGLE:
            return(TRIANGLE);
        }
        return(null);
    }
Ejemplo n.º 11
0
    public Material findMatterial(DustTypes dustType)
    {
        switch (dustType)
        {
        case DustTypes.CUBE:
            return(cubeMat);

        case DustTypes.SPERE:
            return(sphereMat);

        case DustTypes.TRIANGLE:
            return(triangleMat);
        }
        return(null);
    }
Ejemplo n.º 12
0
    public void createSector(ref float zset, int dif)
    {
        DustTypes pass  = (DustTypes)Random.Range(0, 3);
        float     start = zset;

        DustTypes[] failing = failingTypes(pass);

        changeSpeed(new Vector3(0, 0, -(15 + 4 * dif)));

        if (plans.Count > 0)
        {
            for (int i = 0; i < 10; ++i)
            {
                createPlan(new DustTypes[] { pass }, failing, ref zset, plans[Random.Range(0, plans.Count)]);
            }
        }

        int pspawns = Mathf.Max(3, 10 - dif);

        for (int i = 0; i < pspawns; ++i)
        {
            spawnDust(pass, new Vector3(Random.Range(-10.0f, 10.0f),
                                        Random.Range(-5.0f, 5.0f),
                                        Random.Range(start, zset)));
        }

        int dspawns = Mathf.Min(70, 30 + 4 * dif);

        for (int i = 0; i < dspawns; ++i)
        {
            spawnDust(failing[Random.Range(0, failing.Length)], new Vector3(Random.Range(-10.0f, 10.0f),
                                                                            Random.Range(-5.0f, 5.0f),
                                                                            Random.Range(start, zset)));
        }



        zset += 20;

        SpawnWall(pass, zset);

        zset += 30;
    }
Ejemplo n.º 13
0
 void SpawnWall(DustTypes passWallType, float zset)
 {
     GameObject passWallInstance = (GameObject)Instantiate(passWall, new Vector3(0, 0, zset), Quaternion.AngleAxis(-90, new Vector3(1,0,0)));
     passWalls.Add (passWallInstance);
     PassWall script = passWallInstance.GetComponent<PassWall> ();
     script.Setup(passWallType, velocity.z);
     script.Removed += new PassWall.WallRemoved (wallRemoved);
 }
Ejemplo n.º 14
0
    private DustTypes[] failingTypes(DustTypes passingType)
    {
        switch (passingType) {
        case DustTypes.CUBE: return new DustTypes[]{DustTypes.SPERE,DustTypes.TRIANGLE};
        case DustTypes.SPERE: return new DustTypes[]{DustTypes.CUBE,DustTypes.TRIANGLE};
        case DustTypes.TRIANGLE: return new DustTypes[]{DustTypes.SPERE,DustTypes.CUBE};

        }
        return new DustTypes[]{};
    }
Ejemplo n.º 15
0
    private void createPlan(DustTypes[] pass, DustTypes[] fail, ref float zset, Plan plan)
    {
        Vector3 dpos = new Vector3 (0, 0, zset);
        float max = 0;
        foreach (Dust dust in plan.dusts) {
            addTypedDust(dust.key,dust.pos + dpos, pass, fail);
            if(dust.pos.z > max)
                max = dust.pos.z;
        }

        max += 40;

        zset += max;
    }
Ejemplo n.º 16
0
    private void addTypedDust(bool key, Vector3 pos, DustTypes[] pass, DustTypes[] fail)
    {
        if (key && (pass.Length > 0)) {
            spawnDust(pass[Random.Range(0,pass.Length)],pos);
        } else if (!key && (fail.Length > 0)) {

            spawnDust(fail[Random.Range(0,fail.Length)],pos);
        }
    }
Ejemplo n.º 17
0
    public void spawnDust(DustTypes type,Vector3 pos)
    {
        GameObject newDust = (GameObject)Instantiate(startDust, pos, Quaternion.identity);
        dust.Add (newDust);

        StarDust script = newDust.GetComponent<StarDust> ();
        script.Removed += new StarDust.DustRemoved (dustRemoved);
        script.DustType = type;
        script.Velocity = velocity;
        script.spin ();
    }
Ejemplo n.º 18
0
    // events
    void OnTriggerEnter(Collider otherObj)
    {
        if (otherObj.gameObject.tag == "Dust") {

            Vector3 dist = transform.position - otherObj.attachedRigidbody.transform.position;
            float distMag = dist.magnitude;
            if (distMag > COLLISION_RADIUS) {
                if (heldObject == null && Time.realtimeSinceStartup - holdRequestInitateTime < HOLD_TIME_LENIENCY) {
                    heldObject = otherObj.attachedRigidbody;
                }
            } else if (heldObject != otherObj.attachedRigidbody) {
                this.type = otherObj.gameObject.GetComponent<StarDust>().DustType;
                this.GetComponent<MeshFilter>().mesh = otherObj.gameObject.GetComponent<StarDust>().findMesh(type);
                Destroy (otherObj.gameObject);
            }

        }
        else if (otherObj.gameObject.tag == "PassWall")
        {
            if (type != otherObj.GetComponent<PassWall>().type && !lockLife)
            {
                lockLife = true;
                life--;
                myo.GetComponent<ThalmicMyo>().Vibrate (VibrationType.Short);
                if (life <= 0)
                {
                    if ((GameObject.Find("Player1").GetComponent<Ship>().Life <= 0))
                    {
                        if (opposingShip.GetComponent<Ship>().Life <= 0)
                        {
                            GameObject.Find("Spawner").GetComponent<UIDriver>().showStateText("Just... Wow.\nPunch The Screen\nTo Play Again");
                        }
                        else
                        {
                            GameObject.Find("Spawner").GetComponent<UIDriver>().showStateText("Player 1 Has Died\nPunch The Screen\nTo Play Again");
                        }
                    }
                    else
                    {
                        if (opposingShip.GetComponent<Ship>().Life <= 0)
                        {
                            GameObject.Find("Spawner").GetComponent<UIDriver>().showStateText("Both Of You Suck.\nPunch The Screen\nTo Play Again");
                        }
                        else
                        {
                            GameObject.Find("Spawner").GetComponent<UIDriver>().showStateText("Player 2 Has Died\nPunch The Screen\nTo Play Again");
                        }
                    }
                    GameObject.Find("Spawner").GetComponent<UIDriver>().showHUD(false);
                }
                else
                {
                    GameObject.Find("Spawner").GetComponent<UIDriver>().showHUD(true);
                }
            }
        }
    }
Ejemplo n.º 19
0
 public void setType(DustTypes type)
 {
     this.type = type;
 }
Ejemplo n.º 20
0
 public void Setup(DustTypes dustType, float velocity)
 {
     type          = dustType;
     this.velocity = velocity;
 }
Ejemplo n.º 21
0
 public void Setup(DustTypes dustType, float velocity)
 {
     type = dustType;
     this.velocity = velocity;
 }
Ejemplo n.º 22
0
 public void setType(DustTypes type)
 {
     this.type = type;
 }
Ejemplo n.º 23
0
 private void updatePassWall(GameObject obj)
 {
     if (obj.GetComponent<Nemesis>().passWalls.Count > 0)
     {
         prevPassWall = obj.GetComponent<Nemesis>().passWalls[0].GetComponent<PassWall>().type;
         showGateWarning(true);
     }
     else
     {
         showGateWarning(false);
     }
 }
Ejemplo n.º 24
0
 public BoundLiteralExpression(object value)
 {
     Value = DustTypes.FromNative(value);
 }