void MassGatherNeighbors(int alX, int alY)
        {
            int helperX = 1 + ((alX - 1) * 20);
            int helperY = 1 + ((alY - 1) * 20);


            for (int x = helperX; x < helperX + 20; x++)
            {
                for (int y = helperY; y < helperY + 20; y++)
                {
                    MagicPixel k = MagicHandler.instance.GetMagicPixelCoords(x, y, true);
                    if (k != null)
                    {
                        for (int x2 = -1; x2 <= 1; x2++)
                        {
                            for (int y2 = -1; y2 <= 1; y2++)
                            {
                                MagicPixel g = MagicHandler.instance.GetMagicPixelCoords(k.corX + x2, k.corY + y2, true);
                                if (g != null)
                                {
                                    k.neighbors.Add(g);
                                }
                            }
                        }
                    }
                    else
                    {
                        Debug.Log("This is bugging up.");
                    }
                }
            }
            MagicHandler.instance.ObtuseWorkAround(2, this);
        }
        public void GenerateLayer(int alX, int alY)
        {
            int helperX = 1 + ((alX - 1) * 20);
            int helperY = 1 + ((alY - 1) * 20);


            for (int x = helperX; x < helperX + 20; x++)
            {
                for (int y = helperY; y < helperY + 20; y++)
                {
                    MagicPixel pixel = new MagicPixel();

                    pixel.corX  = x;
                    pixel.corY  = y;
                    pixel.pType = MagicHandler.instance.naught;

                    pixel.worldObject = pixelPrefab;

                    pixel.worldPosition = new Vector3(((x * 0.01f) + MagicHandler.instance.anchorOffset.x) + (MagicHandler.instance.cycleCountX - 1) * 3.8f, ((y * 0.01f) + MagicHandler.instance.anchorOffset.y) + (MagicHandler.instance.cycleCountY - 1) * 3.8f, 0f);
                    pixel.myGrid        = this;

                    pixelArray[pixel.corX, pixel.corY] = pixel;
                    pixelList.Add(pixel);
                }
            }

            MagicHandler.instance.ObtuseWorkAround(1, this);
        }
        public MagicPixel GetMagicPixelCoords(int x, int y, bool primary)
        {
            MagicPixel retVal = null;

            if (primary == true)
            {
                retVal = activeGrid.pixelArray[x, y];
            }
            else
            {
                retVal = secondaryGrid.pixelArray[x, y];
            }
            return(retVal);
        }
示例#4
0
        public MagicPixel FindNeighbor(int x, int y)
        {
            MagicPixel retVal = null;

            foreach (MagicPixel neighBoy in neighbors)
            {
                if (neighBoy.corX == corX + x && neighBoy.corY == corY + y)
                {
                    retVal = neighBoy;
                }
            }

            return(retVal);
        }
 public bool GridType(MagicPixel tempPix)
 {
     if (tempPix.myGrid == activeGrid)
     {
         return(true);
     }
     else if (tempPix.myGrid == secondaryGrid)
     {
         return(false);
     }
     else
     {
         return(true);
     }
 }
示例#6
0
        void Update()
        {
            transform.position = Vector3.MoveTowards(this.transform.position, destination, speed * Time.deltaTime);

            if (Vector3.Distance(this.transform.position, destination) < 0.05f)
            {
                Destroy(this.gameObject);
            }

            if (checkTime + 0.1f < Time.fixedTime)
            {
                checkTime = Time.fixedTime;
                MagicPixel nearestPixel = MagicHandler.instance.FindNearestPixel(this.gameObject.transform.position);
                MagicHandler.instance.SummonPixel(nearestPixel, 1, pixelType);
            }
        }
 public void SummonPixel(MagicPixel tempPix, int mass, PixelType pixelType)
 {
     if (tempPix != null)
     {
         bool whichGrid = GridType(tempPix);
         for (int i = mass; i >= -mass; i--)
         {
             for (int s = mass; s >= -mass; s--)
             {
                 MagicPixel o = GetMagicPixelCoords(tempPix.corX + i, tempPix.corY + s, whichGrid);
                 if (o != null)
                 {
                     o.active = true;
                     o.pType  = pixelType;
                 }
             }
         }
     }
 }
        public MagicPixel FindNearestPixel(Vector3 vector)
        {
            MagicPixel retVal   = null;
            float      tempDist = 10000f;

            if (doubleAct == false)
            {
                foreach (MagicPixel m in activeGrid.pixelList)
                {
                    if (Vector3.Distance(vector, m.worldPosition) < tempDist)
                    {
                        tempDist = Vector3.Distance(vector, m.worldPosition);
                        retVal   = m;
                    }
                }
            }
            else
            {
                if (Vector3.Distance(vector, activeGrid.centerVector) > Vector3.Distance(vector, secondaryGrid.centerVector))
                {
                    foreach (MagicPixel m in secondaryGrid.pixelList)
                    {
                        if (Vector3.Distance(vector, m.worldPosition) < tempDist)
                        {
                            tempDist = Vector3.Distance(vector, m.worldPosition);
                            retVal   = m;
                        }
                    }
                }
                else
                {
                    foreach (MagicPixel m in activeGrid.pixelList)
                    {
                        if (Vector3.Distance(vector, m.worldPosition) < tempDist)
                        {
                            tempDist = Vector3.Distance(vector, m.worldPosition);
                            retVal   = m;
                        }
                    }
                }
            }
            return(retVal);
        }
        public MagicPixel GetMagicPixelCoList(Vector3 vector)
        {
            MagicPixel retVal = null;

            if (doubleAct == false)
            {
                foreach (MagicPixel m in activeGrid.pixelList)
                {
                    if (vector == m.worldPosition)
                    {
                        retVal = m;
                    }
                }
            }
            else
            {
                if (Vector3.Distance(vector, activeGrid.centerVector) > Vector3.Distance(vector, secondaryGrid.centerVector))
                {
                    foreach (MagicPixel m in secondaryGrid.pixelList)
                    {
                        if (vector == m.worldPosition)
                        {
                            retVal = m;
                        }
                    }
                }
                else
                {
                    foreach (MagicPixel m in activeGrid.pixelList)
                    {
                        if (vector == m.worldPosition)
                        {
                            retVal = m;
                        }
                    }
                }
            }
            return(retVal);
        }
示例#10
0
        public void TakeBioDamage(float damage, DamageType damageType)
        {
            if (this.gameObject.GetComponent <CharacterData>().isDead == false)
            {
                string descriptor = "";
                if (damage < 5)
                {
                    descriptor = "lightly";
                }
                else if (damage > 15)
                {
                    descriptor = "mortally";
                }

                if ((int)damageType == 0)
                {
                    int whichLimb = Mathf.RoundToInt(Random.Range(0, animate.limbsAndOrgans.Count - 1));
                    animate.limbsAndOrgans[whichLimb].health -= damage;
                    AnnouncerManager.instance.ReceiveText(this.gameObject.GetComponent <CharacterData>().charName + " was " + descriptor + " pierced in their " + animate.limbsAndOrgans[whichLimb].name, false);
                    MagicPixel m = MagicHandler.instance.FindNearestPixel(this.gameObject.transform.position + new Vector3(0f, 0.05f, 0f));
                    MagicHandler.instance.SummonPixel(m, 1, (PixelType)4);
                }
                else if ((int)damageType == 1)
                {
                    int whichLimb = Mathf.RoundToInt(Random.Range(0, animate.limbsAndOrgans.Count - 1));
                    animate.limbsAndOrgans[whichLimb].health -= damage / 2;
                    int whichLimbTwo = Mathf.RoundToInt(Random.Range(0, animate.limbsAndOrgans.Count - 1));
                    animate.limbsAndOrgans[whichLimbTwo].health -= damage / 2;
                    AnnouncerManager.instance.ReceiveText(this.gameObject.GetComponent <CharacterData>().charName + " was " + descriptor + " slashed across their " + animate.limbsAndOrgans[whichLimb].name + " and " + animate.limbsAndOrgans[whichLimbTwo].name, false);
                    MagicPixel m = MagicHandler.instance.FindNearestPixel(this.gameObject.transform.position + new Vector3(0f, 0.05f, 0f));
                    MagicHandler.instance.SummonPixel(m, 1, (PixelType)4);
                }
                else if ((int)damageType == 2)
                {
                    float averageHealth = 0;
                    foreach (OrganOrLimb o in animate.limbsAndOrgans)
                    {
                        averageHealth += o.health;
                    }
                    averageHealth = averageHealth / animate.limbsAndOrgans.Count;
                    AnnouncerManager.instance.ReceiveText(this.gameObject.GetComponent <CharacterData>().charName + " was " + descriptor + " bludgeoned, injuring their ", false);
                    foreach (OrganOrLimb o in animate.limbsAndOrgans)
                    {
                        if (o.health > averageHealth)
                        {
                            o.health -= damage;
                            AnnouncerManager.instance.ReceiveText(o.name, false);
                        }
                    }
                    MagicPixel m = MagicHandler.instance.FindNearestPixel(this.gameObject.transform.position + new Vector3(0f, 0.05f, 0f));
                    MagicHandler.instance.SummonPixel(m, 1, (PixelType)4);
                }
                else if ((int)damageType == 3)
                {
                    foreach (OrganOrLimb o in animate.limbsAndOrgans)
                    {
                        if ((int)o.partType <= 4)
                        {
                            o.health -= damage;
                        }
                    }
                    AnnouncerManager.instance.ReceiveText(this.gameObject.GetComponent <CharacterData>().charName + " was " + descriptor + " burned.", false);
                    MagicPixel m = MagicHandler.instance.FindNearestPixel(this.gameObject.transform.position + new Vector3(0f, 0.05f, 0f));
                    MagicHandler.instance.SummonPixel(m, 1, (PixelType)2);
                }
                else if ((int)damageType == 4)
                {
                    foreach (OrganOrLimb o in animate.limbsAndOrgans)
                    {
                        if ((int)o.partType >= 5 && (int)o.partType != 8)
                        {
                            o.health -= damage;
                        }
                    }
                    AnnouncerManager.instance.ReceiveText(this.gameObject.GetComponent <CharacterData>().charName + descriptor + " bleeds.", false);
                    MagicPixel m = MagicHandler.instance.FindNearestPixel(this.gameObject.transform.position + new Vector3(0f, 0.05f, 0f));
                    MagicHandler.instance.SummonPixel(m, 1, (PixelType)4);
                }
                else if ((int)damageType == 5)
                {
                    foreach (OrganOrLimb o in animate.limbsAndOrgans)
                    {
                        o.health -= damage;
                    }
                    AnnouncerManager.instance.ReceiveText(this.gameObject.GetComponent <CharacterData>().charName + " looks sickly and pale.", false);
                    MagicPixel m = MagicHandler.instance.FindNearestPixel(this.gameObject.transform.position + new Vector3(0f, 0.05f, 0f));
                    MagicHandler.instance.SummonPixel(m, 1, (PixelType)3);
                }
                else if ((int)damageType == 6)
                {
                    foreach (OrganOrLimb o in animate.limbsAndOrgans)
                    {
                        if ((int)o.partType <= 4)
                        {
                            o.health -= damage;
                        }
                    }
                    AnnouncerManager.instance.ReceiveText(this.gameObject.GetComponent <CharacterData>().charName + " was " + descriptor + " burned by frost.", false);
                    MagicPixel m = MagicHandler.instance.FindNearestPixel(this.gameObject.transform.position + new Vector3(0f, 0.05f, 0f));
                    MagicHandler.instance.SummonPixel(m, 1, (PixelType)6);
                }

                if ((int)damageType != 5)
                {
                    EvaluateHealth();
                }

                if (this.gameObject == CharacterData.instance.gameObject)
                {
                    HealthBar.instance.CheckHealth();
                }
            }
        }
        public void Usage()
        {
            AnnouncerManager.instance.ReceiveText("You used the " + this.invenName, false);

            if ((int)this.gameObject.GetComponent <ItemData>().itemType == 0 && EquipmentRenderer.instance.equippedWeapon != this.gameObject && CharacterData.instance.canAttack == true)
            {
                EquipmentManager.instance.Equip(this.gameObject);
            }
            else if ((int)this.gameObject.GetComponent <ItemData>().itemType == 0 && EquipmentRenderer.instance.equippedWeapon == this.gameObject && CharacterData.instance.canAttack == true)
            {
                EquipmentRenderer.instance.Unequip(4, this.gameObject);
            }

            if ((int)this.gameObject.GetComponent <ItemData>().itemType == 1)
            {
                Inventory.instance.bagItems.Remove(this.gameObject);
                CharacterData.instance.health += healCount;
                if (ghostlight != null && CharacterData.instance.ghostlight == null)
                {
                    MagicPixel nearestPixel = MagicHandler.instance.FindNearestPixel(CharacterData.instance.gameObject.transform.position + new Vector3(0f, 0.05f, 0f));
                    MagicHandler.instance.SummonAether(nearestPixel, 5);
                    GameObject g = Instantiate(ghostlight);
                    g.GetComponent <ItemData>().compQuant = 20f;
                    CharacterData.instance.componentsHeld++;
                    CharacterData.instance.ghostlightHeld += 20f;
                    CharacterData.instance.ghostlight      = g;

                    Inventory.instance.items.Add(g);
                    g.GetComponent <ItemData>().isInInven     = true;
                    g.GetComponent <SpriteRenderer>().enabled = false;
                    g.transform.parent = Inventory.instance.gameObject.transform;
                    Inventory.instance.inventoryUI.UpdateUI();
                }
                else if (ghostlight != null && CharacterData.instance.ghostlight != null)
                {
                    MagicPixel nearestPixel = MagicHandler.instance.FindNearestPixel(CharacterData.instance.gameObject.transform.position + new Vector3(0f, 0.05f, 0f));
                    MagicHandler.instance.SummonAether(nearestPixel, 5);
                    CharacterData.instance.ghostlight.GetComponent <ItemData>().compQuant += 20f;
                }

                //We'll add other types of potions later.
                Destroy(this.gameObject);
                CharacterData.instance.potionsHeld -= 1;
            }

            if ((int)this.gameObject.GetComponent <ItemData>().itemType == 2)
            {
                if (hasUse == true)
                {
                    AnnouncerManager.instance.ReceiveText("You used " + invenName, true);
                    //Use it.
                }
                else if (canEat == true)
                {
                    AnnouncerManager.instance.ReceiveText("You ate " + invenName, true);
                    //Eat it.
                }
            }

            if ((int)this.gameObject.GetComponent <ItemData>().itemType == 5)
            {
                BookManager.instance.StartingUp();
            }
        }
示例#12
0
        public void UpdatePixel()
        {
            if (MagicHandler.instance.hasGeneratedGrid == true)
            {
                if (active == true && hasPixel == true)
                {
                    //if (tempObj.GetComponent<PixelHandler>().canBeSeen == true) {

                    int  dirX      = 0;
                    int  dirY      = 0;
                    bool dissipate = false;

                    if ((int)pType == 1)
                    {
                        int i = Random.Range(1, 100);
                        if (i > 5)
                        {
                            dissipate = false;
                            dirX      = Mathf.RoundToInt(Random.Range(-1, 1));
                            dirY      = 1;
                        }
                        else if (i <= 5)
                        {
                            dissipate = true;
                        }
                    }

                    if ((int)pType == 2)
                    {
                        int i = Random.Range(1, 100);
                        if (i > 10)
                        {
                            dissipate = false;
                            dirX      = 1;
                            dirY      = 1;
                        }
                        else if (i <= 10)
                        {
                            dissipate = true;
                        }
                    }

                    if ((int)pType == 3)
                    {
                        int i = Random.Range(1, 100);
                        if (i > 5)
                        {
                            dissipate = false;
                            float ranY = Random.Range(1, 100);
                            if (ranY > 25)
                            {
                                dirY = 1;
                            }
                            else if (ranY > 10)
                            {
                                dirY = 0;
                            }
                            else
                            {
                                dirY = -1;
                            }
                            float ranX = Random.Range(1, 100);
                            if (ranX > 66)
                            {
                                dirX = 1;
                            }
                            else if (ranX > 33)
                            {
                                dirX = 0;
                            }
                            else
                            {
                                dirX = -1;
                            }
                        }
                        else if (i <= 5)
                        {
                            dissipate = true;
                        }
                    }

                    if ((int)pType == 4)
                    {
                        int i = Random.Range(1, 100);
                        if (i > 5)
                        {
                            dissipate = false;
                            float ranY = Random.Range(1, 100);
                            if (ranY < 5)
                            {
                                dirY = 1;
                            }
                            else if (ranY < 15)
                            {
                                dirY = 0;
                            }
                            else
                            {
                                dirY = -1;
                            }
                            float ranX = Random.Range(1, 100);
                            if (ranX > 66)
                            {
                                dirX = 1;
                            }
                            else if (ranX > 33)
                            {
                                dirX = 0;
                            }
                            else
                            {
                                dirX = -1;
                            }
                        }
                        else if (i <= 5)
                        {
                            dissipate = true;
                        }
                    }

                    //Temporary behavior.

                    if ((int)pType >= 5)
                    {
                        int i = Random.Range(1, 100);
                        if (i > 5)
                        {
                            dissipate = false;
                            float ranY = Random.Range(1, 100);
                            if (ranY > 25)
                            {
                                dirY = 1;
                            }
                            else if (ranY > 10)
                            {
                                dirY = 0;
                            }
                            else
                            {
                                dirY = -1;
                            }
                            float ranX = Random.Range(1, 100);
                            if (ranX > 66)
                            {
                                dirX = 1;
                            }
                            else if (ranX > 33)
                            {
                                dirX = 0;
                            }
                            else
                            {
                                dirX = -1;
                            }
                        }
                        else if (i <= 5)
                        {
                            dissipate = true;
                        }
                    }

                    //Add the behavior of various particles here.

                    if (dissipate == false)
                    {
                        MagicPixel actNeigh = FindNeighbor(dirX, dirY);
                        if (actNeigh != null)
                        {
                            if (actNeigh.active == false)
                            {
                                actNeigh.active = true;
                                actNeigh.pType  = pType;

                                active = false;
                            }
                        }
                    }
                    else
                    {
                        active = false;
                    }
                }

                if (active == true && hasPixel == false)
                {
                    hasPixel = true;
                    GameObject g = MagicHandler.instance.CreatePhysicalPixel(worldObject);
                    g.GetComponent <PixelHandler>().SetType((int)pType);
                    g.transform.position = worldPosition;
                    tempObj = g;
                }

                if (active == false && hasPixel == true)
                {
                    MagicHandler.instance.DestroyPhysicalPixel(tempObj);
                    hasPixel = false;
                }
            }
        }