Пример #1
0
 void OnTriggerEnter(Collider c)
 {
     if (c.gameObject.transform.tag == "Enemy")
     {
         LibPD.SendMessage("BoomPos", "float", (this.transform.position.x - 20) / 40);
         LibPD.SendMessage("BoomBang", "bang");
         Explode();
     }
 }
Пример #2
0
 public void TakeDamage(int amount)
 {
     health -= amount;
     if (health <= 0)
     {
         //weird error
         LibPD.SendMessage("DeathPos", "float", (this.transform.position.x - 20) / 40);
         LibPD.SendMessage("DeathBang", "bang");
         Destroy(gameObject);
         spawner.unitsInWave--;
     }
 }
Пример #3
0
 void OnMouseOver()
 {
     transform.localScale = new Vector3(myScale.x + 0.2f, myScale.y + 0.2f, myScale.z + 0.2f);
     //Select objects
     if (Input.GetMouseButtonDown(0))
     {
         if (!select)
         {
             LibPD.SendMessage("CubePos", "float", (this.transform.position.x / 15) + 0.5f);
             LibPD.SendMessage("CubeBang", "bang");
             select = transform;
         }
         else if (select != transform && !moveTo)              //If one block selected, then check if we are not selecting same block again, select second block
         {
             moveTo = transform;
         }
     }
 }
Пример #4
0
    // Update is called once per frame
    void Update()
    {
        int i;

        Collider[] targets = Physics.OverlapSphere(this.transform.position, 5);
        if (targets.Length > 0)
        {
            for (i = 0; i < targets.Length;)
            {
                if (targets[i].gameObject.tag == "Enemy")
                {
                    break;
                }
                else
                {
                    i++;
                }
            }
            if (Time.time >= nextFireTime)
            {
                nextFireTime = Time.time + reloadTime;
                this.transform.LookAt(targets[i].transform.position);
                Instantiate(projectile, transform.position, transform.rotation);
                if ((gameObject.name).Equals("BombTower"))
                {
                    LibPD.SendMessage("bombTowerPos", "float", (this.transform.position.x - 20) / 40);
                    LibPD.SendMessage("bombTowerBang", "bang");
                }
                else
                {
                    LibPD.SendMessage("TowerPos", "float", (this.transform.position.x - 20) / 40);
                    LibPD.SendMessage("TowerBang", "bang");
                }
            }
        }
    }
Пример #5
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetMouseButtonDown(0))
        {
            GameEventManager.TriggerGameStart();
        }
        if (lives < 1)
        {
            gameOver = true;
        }

        //only every 50th update to not take up to many rescources.
        if (updateSound > 50)
        {
            LibPD.SendMessage("sfxVolume", "float", sfxVolume);
            LibPD.SendMessage("musicVolume", "float", musicVolume);
            LibPD.SendMessage("masterVolume", "float", masterVolume);
            updateSound = 0;
        }
        else
        {
            updateSound++;
        }
    }
Пример #6
0
 public bool SendMessage <T>(string receiverName, string message, params T[] arguments)
 {
     return(LibPD.SendMessage(receiverName, message, arguments) == 0);
 }
Пример #7
0
 // Use this for initialization
 void Start()
 {
     LibPD.SendMessage("Load-current-melody", "bang");
     LibPD.SendMessage("bpm", "float", 120f);
     LibPD.SendMessage("musicVolume", "float", 1f);
 }
Пример #8
0
 public static void SetInstrumentMode(int instrumentNumber, int mode)
 {
     LibPD.SendMessage(PrependDollarZero("instrument" + instrumentNumber), "mode", new object[] { mode });
 }
Пример #9
0
 public static void LoadInstrument(int instrumentNumber, string instrument)
 {
     LibPD.SendMessage(PrependDollarZero("instrument" + instrumentNumber), "sample", new object[] { instrument });
 }
Пример #10
0
    bool CheckMatch()
    {
        //Check for any mistake in the board
        testBoard();

        //Get all blocks in scene
        Block[] allb = FindObjectsOfType(typeof(Block)) as Block[];
        Block   sel  = Block.select.gameObject.GetComponent <Block> ();
        Block   mov  = Block.moveTo.gameObject.GetComponent <Block> ();



        //SELECTED BLOCK
        //Check how many blocks have same ID as our selected block(for each direction)
        int countU = 0;         //Count Up
        int countD = 0;         //Count Down
        int countL = 0;         //Count Left
        int countR = 0;         //Count RIght

        //Check how many same blocks have sam ID...
        //Left
        for (int l = sel.x - 1; l >= 0; l--)
        {
            if (board[l, sel.y] == sel.ID)         //If block have same ID
            {
                countL++;
            }
            if (board[l, sel.y] != sel.ID)         //If block have same ID
            {
                break;
            }
        }
        //Right
        for (int r = sel.x; r < board.GetLength(0); r++)
        {
            if (board[r, sel.y] == sel.ID)         //If block have same ID
            {
                countR++;
            }
            if (board[r, sel.y] != sel.ID)         //If block have same ID
            {
                break;
            }
        }
        //Down
        for (int d = sel.y - 1; d >= 0; d--)
        {
            if (board[sel.x, d] == sel.ID)
            {
                countD++;
            }
            if (board[sel.x, d] != sel.ID)
            {
                break;
            }
        }

        //Up
        for (int u = sel.y; u < board.GetLength(1); u++)
        {
            if (board[sel.x, u] == sel.ID)
            {
                countU++;
            }

            if (board[sel.x, u] != sel.ID)
            {
                break;
            }
        }

        //MOVE TO BLOCK
        int countUU = 0;         //Count Up
        int countDD = 0;         //Count Down
        int countLL = 0;         //Count Left
        int countRR = 0;         //Count RIght

        //Check how many same blocks have sam ID...
        //Left
        for (int l = mov.x - 1; l >= 0; l--)
        {
            if (board[l, mov.y] == mov.ID)         //If block have same ID
            {
                countLL++;
            }
            if (board[l, mov.y] != mov.ID)         //If block have same ID
            {
                break;
            }
        }
        //Right
        for (int r = mov.x; r < board.GetLength(0); r++)
        {
            if (board[r, mov.y] == mov.ID)         //If block have same ID
            {
                countRR++;
            }
            if (board[r, mov.y] != mov.ID)         //If block have same ID
            {
                break;
            }
        }
        //Down
        for (int d = mov.y - 1; d >= 0; d--)
        {
            if (board[mov.x, d] == mov.ID)
            {
                countDD++;
            }
            if (board[mov.x, d] != mov.ID)
            {
                break;
            }
        }

        //Up
        for (int u = mov.y; u < board.GetLength(1); u++)
        {
            if (board[mov.x, u] == mov.ID)
            {
                countUU++;
            }

            if (board[mov.x, u] != mov.ID)
            {
                break;
            }
        }



        //Check if there is 3+ match
        if ((countL + countR >= 3 || countD + countU >= 3) || (countLL + countRR >= 3 || countDD + countUU >= 3))
        {
            if (countL + countR >= 3)
            {
                //Destroy and mark empty block
                for (int cl = 0; cl <= countL; cl++)
                {
                    foreach (Block b in allb)
                    {
                        if (b.x == sel.x - cl && b.y == sel.y)
                        {
                            b.StartCoroutine("destroyBlock");
                            board[b.x, b.y] += 500;                            //To mark empty block
                        }
                    }
                }
                for (int cr = 0; cr < countR; cr++)
                {
                    foreach (Block b in allb)
                    {
                        if (b.x == sel.x + cr && b.y == sel.y)
                        {
                            b.StartCoroutine("destroyBlock");
                            board[b.x, b.y] += 500;                            //To mark empty block
                        }
                    }
                }
            }
            if (countD + countU >= 3)
            {
                for (int cd = 0; cd <= countD; cd++)
                {
                    foreach (Block blc in allb)
                    {
                        if (blc.x == sel.x && blc.y == sel.y - cd)
                        {
                            board[blc.x, blc.y] += 500;
                            blc.StartCoroutine("destroyBlock");
                        }
                    }
                }
                for (int cu = 0; cu < countU; cu++)
                {
                    foreach (Block blc in allb)
                    {
                        if (blc.x == sel.x && blc.y == sel.y + cu)
                        {
                            board[blc.x, blc.y] += 500;
                            blc.StartCoroutine("destroyBlock");
                        }
                    }
                }
            }



            if (countLL + countRR >= 3)
            {
                //Destroy and mark empty block
                for (int cl = 0; cl <= countLL; cl++)
                {
                    foreach (Block b in allb)
                    {
                        if (b.x == mov.x - cl && b.y == mov.y)
                        {
                            b.StartCoroutine("destroyBlock");
                            board[b.x, b.y] += 500;                            //To mark empty block
                        }
                    }
                }
                for (int cr = 0; cr < countRR; cr++)
                {
                    foreach (Block b in allb)
                    {
                        if (b.x == mov.x + cr && b.y == mov.y)
                        {
                            b.StartCoroutine("destroyBlock");
                            board[b.x, b.y] += 500;                            //To mark empty block
                        }
                    }
                }
            }
            if (countDD + countUU >= 3)
            {
                for (int cd = 0; cd <= countDD; cd++)
                {
                    foreach (Block blc in allb)
                    {
                        if (blc.x == mov.x && blc.y == mov.y - cd)
                        {
                            board[blc.x, blc.y] += 500;
                            blc.StartCoroutine("destroyBlock");
                        }
                    }
                }
                for (int cu = 0; cu < countUU; cu++)
                {
                    foreach (Block blc in allb)
                    {
                        if (blc.x == mov.x && blc.y == mov.y + cu)
                        {
                            board[blc.x, blc.y] += 500;
                            blc.StartCoroutine("destroyBlock");
                        }
                    }
                }
            }
            //Respawn blocks
            MoveY();
            //score = setScore (finalID, blocksDestroyed);
            GUIManager.SetCurrentNumber(score);
            if (score == goal || score > goal)
            {
                GameEventManager.TriggerGameOver();
            }
            //blocksDestroyed = 0;
            LibPD.SendMessage("StrumBang", "bang");
            return(true);
        }



        return(false);
    }
Пример #11
0
        public virtual void testReceive()
        {
            var receiver = "spam";
            var listArgs = new object[] { "hund", 1, "katze", 2.5, "maus", 3.1f };
            var msgName  = "testing";
            var msgArgs  = new object[] { "one", 1, "two", 2 };

            LibPD.Subscribe(receiver);

            var n = 0;

            LibPDBang delBang = delegate(string recv) {
                Assert.AreEqual(receiver, recv);
                n++;
            };

            LibPD.Bang += delBang;

            LibPDFloat delFloat = delegate(string recv, float x) {
                Assert.AreEqual(receiver, recv);
                Assert.AreEqual(42, x);
                n++;
            };

            LibPD.Float += delFloat;

            LibPDSymbol delSymbol = delegate(string recv, string sym) {
                Assert.AreEqual(receiver, recv);
                Assert.AreEqual("hund katze maus", sym);
                n++;
            };

            LibPD.Symbol += delSymbol;

            LibPDList delList = delegate(string recv, object[] args) {
                Assert.AreEqual(receiver, recv);
                Assert.AreEqual(listArgs.Length, args.Length);

                for (int i = 0; i < args.Length; i++)
                {
                    Assert.AreEqual(listArgs [i], args [i]);
                }
                n++;
            };

            LibPD.List += delList;

            LibPDMessage delMessage = delegate(string recv, string msg, object[] args) {
                Assert.AreEqual(receiver, recv);
                Assert.AreEqual(msgName, msg);
                Assert.AreEqual(msgArgs.Length, args.Length);

                for (int i = 0; i < args.Length; i++)
                {
                    Assert.AreEqual(msgArgs [i], args [i]);
                }
                n++;
            };

            LibPD.Message += delMessage;

            LibPD.SendBang(receiver);
            LibPD.SendFloat(receiver, 42);
            LibPD.SendSymbol(receiver, "hund katze maus");
            LibPD.SendList(receiver, listArgs);
            LibPD.SendMessage(receiver, msgName, msgArgs);

            Assert.AreEqual(5, n);

            LibPD.Bang    -= delBang;
            LibPD.Float   -= delFloat;
            LibPD.Symbol  -= delSymbol;
            LibPD.List    -= delList;
            LibPD.Message -= delMessage;
        }