Ejemplo n.º 1
0
 public PlanetPrefab(PlanetPrefab clone, string _name)
 {
     name         = _name;
     typeOfPlanet = clone.typeOfPlanet;
     sprite       = clone.sprite;
     prefab       = clone.prefab;
 }
Ejemplo n.º 2
0
    /// <summary>
    /// Активация первого бонуса квадрата
    /// </summary>
    /// <param name="x">Положение X</param>
    /// <param name="y">Положение Y</param>
    public static void BoxFirstBonusActivate(int x, int y, TypeOfPlanet typeOfPlanet)
    {
        bonusController.slotController.slots[x, y].planet.dontDestroy = true;


        for (int i = x - 1; i <= x + 1; i++)
        {
            for (int j = y - 1; j <= y + 1; j++)
            {
                if (i >= 0 && j >= 0 && i < SlotController.sizeField && j < SlotController.sizeField && (i != x || j != y))
                {
                    bonusController.slotController.slots[i, j].DestroyPlanetInSlot();
                }
            }
        }

        //bonusController.slotController.GeneratePlanet(typeOfPlanet, bonusController.slotController.slots[x, y]);

        AddBoxSecondBonus(bonusController.slotController.slots[x, y]);

        bonusController.slotController.slots[x, y].planet.gameObject.AddComponent <FlickeringSprite>().SetFlickering(2, Ease.OutSine, Ease.InSine);

        SlotController.CanPlanetMove = false;

        bonusController.slotController.slots[x, y].planet.DestroyWhenCanMove();
    }
Ejemplo n.º 3
0
    /// <summary>
    /// Активация бонуса
    /// </summary>
    /// <param name="x">Положение X</param>
    /// <param name="y">Положение Y</param>
    /// <param name="typeOfBonus">Тип бонуса</param>
    public static void ActivateBonus(int x, int y, TypeOfPlanet typeOfPlanet, TypeOfBonus typeOfBonus, TypeOfBonus typeOfExPlanetBonus = TypeOfBonus.None)
    {
        switch (typeOfBonus)
        {
        case TypeOfBonus.HorizontalLine:
        {
            HorizontalLineActivate(x, y);
            break;
        }

        case TypeOfBonus.VerticalLine:
        {
            VerticalLineActivate(x, y);
            break;
        }

        case TypeOfBonus.BoxFirst:
        {
            BoxFirstBonusActivate(x, y, typeOfPlanet);
            break;
        }

        case TypeOfBonus.BoxSecond:
        {
            BoxSecondActivate(x, y);
            break;
        }

        case TypeOfBonus.Star:
        {
            StarBonusActivate(x, y, typeOfPlanet, typeOfExPlanetBonus);
            break;
        }
        }
    }
Ejemplo n.º 4
0
    /// <summary>
    /// Генерирует планету в слоте
    /// </summary>
    /// <param name="typeOfPlanet">Тип планеты</param>
    /// <param name="slot">Слот</param>
    /// <returns>Планета</returns>
    public Planet GeneratePlanet(TypeOfPlanet typeOfPlanet, Slot slot)
    {
        PlanetPrefab initPlanetPrefab = planetPrefabs.Find(x => x.typeOfPlanet == typeOfPlanet);
        Planet       initPlanet       = Instantiate(initPlanetPrefab.prefab, slot.transform).GetComponent <Planet>();

        initPlanet.transform.position = slot.transform.position;
        initPlanet.typeOfPlanet       = initPlanetPrefab.typeOfPlanet;
        initPlanet.SetSprite(initPlanetPrefab.sprite);
        slot.planet     = initPlanet;
        initPlanet.slot = slot;
        return(initPlanet);
    }
Ejemplo n.º 5
0
 public static void StarBonusActivate(int x, int y, TypeOfPlanet typeOfPlanet, TypeOfBonus typeOfExPlanetBonus)
 {
     for (int i = 0; i < SlotController.sizeField; i++)
     {
         for (int j = 0; j < SlotController.sizeField; j++)
         {
             if (bonusController.slotController.slots[i, j].planet != null && bonusController.slotController.slots[i, j].planet.typeOfPlanet == typeOfPlanet)
             {
                 Slot       destroySlot = bonusController.slotController.slots[i, j];
                 GameObject initLine    = Instantiate(bonusController.starLinePrefab, bonusController.slotController.slots[x, y].transform.position, bonusController.slotController.slots[x, y].transform.rotation);
                 initLine.GetComponent <TrailRenderer>().sortingOrder = 1;
                 initLine.transform.DOMove(bonusController.slotController.slots[i, j].transform.position, 0.5f).OnComplete(delegate
                 {
                     Destroy(initLine);
                     if (typeOfExPlanetBonus == TypeOfBonus.None)
                     {
                         destroySlot.DestroyPlanetInSlot();
                     }
                     else
                     {
                         if (destroySlot == bonusController.slotController.slots[x, y])
                         {
                             destroySlot.DestroyPlanetInSlot();
                         }
                         else
                         {
                             if (!destroySlot.planet.HaveLineBonus())
                             {//рандомное значение: вертикальный или горизонтальный бонус
                                 destroySlot.planet.SetDirectionOfMove();
                                 AddLineBonus(destroySlot);
                                 destroySlot.planet.SetBonus(typeOfExPlanetBonus);
                             }
                             bonusController.planetsForDestruction.Add(destroySlot.planet);
                         }
                     }
                 });
             }
         }
     }
     SlotController.CanPlanetMove = true;
 }
Ejemplo n.º 6
0
    public void MoveToSlot(Slot slotToMove, Planet exPlanet)
    {
        directionOfMove = TypeLineBonus.Verical;

        if (slot.x == slotToMove.x)
        {
            directionOfMove = TypeLineBonus.Verical;
        }
        if (slot.y == slotToMove.y)
        {
            directionOfMove = TypeLineBonus.Horizontal;
        }

        if (slot != null)
        {
            slot.planet = null;
        }
        slot = null;
        slotToMove.planet = this;
        transform.DOMove(slotToMove.transform.position, speedMove).SetEase(Ease.Linear).OnUpdate(
            delegate
        {
            if (slot != null)
            {
                SlotController.CanPlanetMove = false;
            }
        }).OnComplete(delegate
        {
            if (HaveStarBonus())
            {
                typeOfPlanet = exPlanet.typeOfPlanet;
                if (exPlanet.CountBonus() != 0)
                {
                    typeOfExPlanetBonus = exPlanet.bonuses[0];
                }
            }
            OnCompliteMove(slotToMove);
        });
    }