Esempio n. 1
0
 private void setColour(GameObject gameObject, ColourObject colourObject)
 {
     if (colourObject.colourName() == ColourObject.RED_NAME)
     {
         gameObject.GetComponent <Renderer>().material.color = Color.red;
     }
     else if (colourObject.colourName() == ColourObject.BLUE_NAME)
     {
         gameObject.GetComponent <Renderer>().material.color = Color.blue;
     }
     else if (colourObject.colourName() == ColourObject.GREEN_NAME)
     {
         gameObject.GetComponent <Renderer>().material.color = Color.green;
     }
     else if (colourObject.colourName() == ColourObject.PURPLE_NAME)
     {
         gameObject.GetComponent <Renderer>().material.color = new Color(1, 0, 1, 1);
     }
     else if (colourObject.colourName() == ColourObject.ORANGE_NAME)
     {
         gameObject.GetComponent <Renderer>().material.color = new Color(1, (float)0.5, 0, 1);
     }
     else if (colourObject.colourName() == ColourObject.YELLOW_NAME)
     {
         gameObject.GetComponent <Renderer>().material.color = Color.yellow;
     }
     else if (colourObject.colourName() == ColourObject.WHITE_NAME)
     {
         gameObject.GetComponent <Renderer>().material.color = Color.white;
     }
     else if (colourObject.colourName() == ColourObject.BLACK_NAME)
     {
         gameObject.GetComponent <Renderer>().material.color = Color.black;
     }
 }
Esempio n. 2
0
 /**
  * Adds a colour to the stack if it is not full, does nothing if it is
  **/
 public void pushToStack(ColourObject colourObject)
 {
     if (paintStack.Count < MAX_STACK_CAPACITY && paintStack.Count >= 0)
     {
         pushColor(colourObject);
     }
     else
     {
         throw new System.Exception("Stack Size is invalid. Stack Size: " + paintStack.Count);
     }
 }
Esempio n. 3
0
    // Use this for initialization
    void Awake()
    {
        myColour = new ColourObject(red, blue, yellow);


        myRB    = this.GetComponent <Rigidbody2D>();
        anim    = this.GetComponent <Animator>();
        myTrans = this.GetComponent <Transform>();
        //StartCoroutine(changeDirectionAfter(changeTime)); //Use to change direction after time instead of collision
        UpdateCol();
    }
Esempio n. 4
0
 void PaintMyself()
 {
     if (PaintManager.instance.getStackSize() > 0)
     {
         if (Time.time > nextFire)
         {
             if (PaintManager.instance.getStackSize() > 0)
             {
                 playerCol = PaintManager.instance.popFromStack();
                 if (playerCol.colourName().Equals("Red"))
                 {
                     anim.runtimeAnimatorController = Resources.Load <RuntimeAnimatorController>("Animation/Man/Red/redcontroller");
                 }
                 else if (playerCol.colourName().Equals("Blue"))
                 {
                     anim.runtimeAnimatorController = Resources.Load <RuntimeAnimatorController>("Animation/Man/Blue/bluecontroller");
                 }
                 else if (playerCol.colourName().Equals("Yellow"))
                 {
                     anim.runtimeAnimatorController = Resources.Load <RuntimeAnimatorController>("Animation/Man/Yellow/yellowcontroller");
                 }
                 else if (playerCol.colourName().Equals("Black"))
                 {
                     anim.runtimeAnimatorController = Resources.Load <RuntimeAnimatorController>("Animation/Man/Black/blackcontroller");
                 }
                 else if (playerCol.colourName().Equals("White"))
                 {
                     anim.runtimeAnimatorController = Resources.Load <RuntimeAnimatorController>("Animation/Man/White/whitecontroller");
                 }
                 else if (playerCol.colourName().Equals("Purple"))
                 {
                     anim.runtimeAnimatorController = Resources.Load <RuntimeAnimatorController>("Animation/Man/Purple/purplecontroller");
                 }
                 else if (playerCol.colourName().Equals("Orange"))
                 {
                     anim.runtimeAnimatorController = Resources.Load <RuntimeAnimatorController>("Animation/Man/Orange/orangecontroller");
                 }
                 else if (playerCol.colourName().Equals("Green"))
                 {
                     anim.runtimeAnimatorController = Resources.Load <RuntimeAnimatorController>("Animation/Man/Green/greencontroller");
                 }
             }
         }
     }
 }
Esempio n. 5
0
    void pushColor(ColourObject newColour)
    {
        GameObject gobject = listOfBlocks[paintStack.Count];

        if (gobject.activeSelf == false)
        {
            gobject.SetActive(true);
        }

        if (newColour.colourName() == ColourObject.RED_NAME)
        {
            gobject.GetComponent <UnityEngine.UI.Image>().overrideSprite = listOfSprites[0];
        }
        else if (newColour.colourName() == ColourObject.BLUE_NAME)
        {
            gobject.GetComponent <UnityEngine.UI.Image>().overrideSprite = listOfSprites[2];
        }
        else if (newColour.colourName() == ColourObject.GREEN_NAME)
        {
            gobject.GetComponent <UnityEngine.UI.Image>().overrideSprite = listOfSprites[5];
        }
        else if (newColour.colourName() == ColourObject.PURPLE_NAME)
        {
            gobject.GetComponent <UnityEngine.UI.Image>().overrideSprite = listOfSprites[3];
        }
        else if (newColour.colourName() == ColourObject.ORANGE_NAME)
        {
            gobject.GetComponent <UnityEngine.UI.Image>().overrideSprite = listOfSprites[4];
        }
        else if (newColour.colourName() == ColourObject.YELLOW_NAME)
        {
            gobject.GetComponent <UnityEngine.UI.Image>().overrideSprite = listOfSprites[1];
        }
        else if (newColour.colourName() == ColourObject.WHITE_NAME)
        {
            gobject.GetComponent <UnityEngine.UI.Image>().overrideSprite = listOfSprites[6];
        }
        paintStack.Push(newColour);
    }
Esempio n. 6
0
    //Merges the top 2 colours in the stack
    public void mergeStack()
    {
        //Cannot merge less than 2 colours
        if (paintStack.Count >= MIN_TO_MERGE && paintStack.Count <= MAX_STACK_CAPACITY)
        {
            ColourObject firstColor  = popFromStack();
            ColourObject secondColor = popFromStack();

            List <string> colourNames = new List <string>();
            colourNames.Add(firstColor.colourName());
            colourNames.Add(secondColor.colourName());

            //To keep track if merging is possible
            Boolean      canMerge  = false;
            ColourObject newColour = new ColourObject(false, false, false);

            if (colourNames.Contains(ColourObject.RED_NAME))
            {
                if (colourNames.Contains(ColourObject.BLUE_NAME))
                {
                    //Purple
                    newColour = new ColourObject(true, true, false);
                    canMerge  = true;
                }
                else if (colourNames.Contains(ColourObject.YELLOW_NAME))
                {
                    //Orange
                    newColour = new ColourObject(true, false, true);
                    canMerge  = true;
                }
                else if (colourNames.Contains(ColourObject.GREEN_NAME))
                {
                    //White
                    newColour = new ColourObject(true, true, true);
                    canMerge  = true;
                }
            }
            else if (colourNames.Contains(ColourObject.BLUE_NAME))
            {
                if (colourNames.Contains(ColourObject.YELLOW_NAME))
                {
                    //Green
                    newColour = new ColourObject(false, true, true);
                    canMerge  = true;
                }
                else if (colourNames.Contains(ColourObject.ORANGE_NAME))
                {
                    //White
                    newColour = new ColourObject(true, true, true);
                    canMerge  = true;
                }
            }
            else if (colourNames.Contains(ColourObject.YELLOW_NAME))
            {
                if (colourNames.Contains(ColourObject.PURPLE_NAME))
                {
                    //White
                    newColour = new ColourObject(true, true, true);
                    canMerge  = true;
                }
            }
            else if (colourNames.Contains(ColourObject.ORANGE_NAME))
            {
                if (colourNames.Contains(ColourObject.PURPLE_NAME) || colourNames.Contains(ColourObject.GREEN_NAME))
                {
                    //White
                    newColour = new ColourObject(true, true, true);
                    canMerge  = true;
                }
            }
            else if (colourNames.Contains(ColourObject.PURPLE_NAME))
            {
                if (colourNames.Contains(ColourObject.GREEN_NAME))
                {
                    //White
                    newColour = new ColourObject(true, true, true);
                    canMerge  = true;
                }
            }
            if (canMerge)
            {
                //If can merge, push the merged colour in
                pushColor(newColour);
            }
            else
            {
                // If cannot merge, just push back the original two colours
                pushColor(secondColor);
                pushColor(firstColor);
            }
        }
    }
Esempio n. 7
0
 // Use this for initialization
 void Start()
 {
     enemyColour = this.gameObject.GetComponent <EnemyManager>().myColour;
 }
Esempio n. 8
0
 public void damage(ColourObject other)
 {
     if (other.getIsRed())               // Bullet has red
     {
         if (other.getIsBlue())
         {                            // Bullet has red and blue
             if (other.getIsYellow()) // Bullet is white
             {
                 makeDead();
             }
             else if (enemyColour.getIsYellow()) // Bullet is purple and Enemy has yellow
             {
                 makeDead();
             }
             else if (enemyColour.getIsRed() || enemyColour.getIsBlue()) // Bullet is purple and enemy has Red or Blue and no Yellow
             {
                 enemyColour.isRed  = true;
                 enemyColour.isBlue = true;
                 this.gameObject.GetComponent <EnemyManager>().UpdateCol();
             }
         }
         else if (other.getIsYellow())    // Bullet is orange
         {
             if (enemyColour.getIsBlue()) // Enemy has blue
             {
                 makeDead();
             }
             else if (enemyColour.getIsRed() || enemyColour.getIsYellow()) // Bullet is orange and enemy has Red or Yellow but no blue
             {
                 enemyColour.isRed    = true;
                 enemyColour.isYellow = true;
                 this.gameObject.GetComponent <EnemyManager>().UpdateCol();
             }
         }
         else // Bullet is red
         {
             if (enemyColour.getIsBlue() && enemyColour.getIsYellow())    // Enemy is green
             {
                 makeDead();
             }
             else
             {
                 enemyColour.isRed = true;
                 this.gameObject.GetComponent <EnemyManager>().UpdateCol();
             }
         }
     }
     else if (other.getIsBlue())         // Bullet has no red but has blue
     {
         if (other.getIsYellow())        // Bullet is green
         {
             if (enemyColour.getIsRed()) // Enemy has red
             {
                 makeDead();
             }
             else if (enemyColour.getIsBlue() || enemyColour.getIsYellow()) // Bullet is green and enemy has Blue or Yellow but no red
             {
                 enemyColour.isBlue   = true;
                 enemyColour.isYellow = true;
                 this.gameObject.GetComponent <EnemyManager>().UpdateCol();
             }
         }
         else if (enemyColour.getIsYellow()) // Bullet is blue and Enemy has yellow
         {
             if (enemyColour.getIsRed())     // Enemy is orange
             {
                 makeDead();
             }
         }
         else
         {
             enemyColour.isBlue = true;
             this.gameObject.GetComponent <EnemyManager>().UpdateCol();
         }
     }
     else if (other.getIsYellow())       // Bullet is yellow
     {
         if (enemyColour.getIsBlue())    // Enemy has blue
         {
             if (enemyColour.getIsRed()) // Enemy is purple
             {
                 makeDead();
             }
         }
         enemyColour.isYellow = true;
         this.gameObject.GetComponent <EnemyManager>().UpdateCol();
     }
 }
Esempio n. 9
0
 // Use this for initialization
 void Start()
 {
     rb        = this.GetComponent <Rigidbody2D>();
     playerCol = new ColourObject(true, false, false);
     anim      = this.GetComponent <Animator>();
 }
Esempio n. 10
0
 // Use this for initialization
 void Start()
 {
     keyCol = new ColourObject(isRed, isBlue, isYellow);
 }
Esempio n. 11
0
 Boolean canMerge(ColourObject other)
 {
     return(this.isRed != other.getIsRed() || this.isBlue != other.getIsBlue() || this.isYellow != other.getIsYellow());
 }