//DrMario Scoring:
        //Lines are worthless, obviously
        //Critical Masses add lots of value
        //groups of the same colour add value
        //additionally, columns of a colour with only air in-between as well as possible colour drops
        //(if the bottom colour of a stuck stack fell as far as it could would line up with other of the same colour

        public IEnumerable <MassItem> FindMasses(StoredBoardState.DrMarioScoringRuleData data, StoredBoardState state)
        {
            List <LineSeriesBlock> ConsideredResults = new List <LineSeriesBlock>();


            for (int r = 0; r < state.RowCount; r++)
            {
                for (int c = 0; c < state.ColCount; c++)
                {
                    if (state.State[r][c] is LineSeriesBlock lsb)
                    {
                        //check for a mass here.
                        var HorizontalMass = FindHorizontalMass(data, state, r, c, lsb.CombiningIndex, ConsideredResults).ToList();
                        var VerticalMass   = FindVerticalMass(data, state, r, c, lsb.CombiningIndex, ConsideredResults).ToList();
                        ConsideredResults.Add(lsb);
                        if (HorizontalMass.Count > 1)
                        {
                            MassItem HorzMass = new MassItem(HorizontalMass);
                            yield return(HorzMass);
                        }
                        if (VerticalMass.Count > 1)
                        {
                            MassItem VertMass = new MassItem(VerticalMass);
                            yield return(VertMass);
                        }
                    }
                }
            }
        }
    void CheckCollision(Collider other)
    {
        if (!IsOperationable)
        {
            return;
        }

        ObstacleItem obstacle = other.gameObject.GetComponent <ObstacleItem>();

        if (obstacle != null)
        {
            if (energySkillCdController.Active)
            {
                energySkillCdController.Active = false;
            }
            else
            {
                GameControl.Instance.GameOver();
            }
            return;
        }

        BombItem bombItem = other.gameObject.GetComponent <BombItem>();

        if (bombItem != null)
        {
            bombItem.Trigger();
            return;
        }

        bool       eat        = false;
        EnergyItem energyItem = other.gameObject.GetComponent <EnergyItem> ();

        if (energyItem != null)
        {
            energyValueController.AddValue(energyItem.Value);
            eat = true;
        }

        MassItem massItem = other.gameObject.GetComponent <MassItem>();

        if (massItem != null)
        {
            Config config = Config.Instance;
            if (_massItem.Value >= massItem.Value * config.absorbLimit)
            {
                // eat it
                _massItem.Value += massItem.Value * config.absorbRate;
                eat              = true;
            }
        }

        if (eat)
        {
            GameControl.Instance.RemoveItem(other.gameObject);
        }
    }
Exemple #3
0
 void Awake()
 {
     _rb = GetComponent<Rigidbody>();
     _massItem = GetComponent<MassItem>();
     _massItem.onValueChangedCallBack += OnMassItemValueChanged;
 }
    public bool ExplodeAction(Vector3 explosionPos, float radius)
    {
        Vector3 closestPoint = _coll.ClosestPointOnBounds(explosionPos);
        float   distance     = Vector3.Distance(closestPoint, explosionPos);

        if (radius > distance)
        {
            int   pieceNum  = bombPiecesRangeController.RandInRange();
            float currValue = 0;
            {
                EnergyItem energyItem = GetComponent <EnergyItem> ();
                if (energyItem != null)
                {
                    currValue        = energyItem.Value;
                    energyItem.Value = currValue * (1 - bombRate);
                }
                MassItem massItem = GetComponent <MassItem> ();
                if (massItem != null)
                {
                    currValue      = massItem.Value;
                    massItem.Value = currValue * (1 - bombRate);
                }
                currValue = currValue * bombRate;
            }
            while (pieceNum > 1)
            {
                float resValue = currValue / pieceNum;
                if (resValue > explodeLimit)
                {
                    for (int i = 0; i < pieceNum; i++)
                    {
                        GameObject item       = Instantiate(piecePerfab);
                        EnergyItem energyItem = item.GetComponent <EnergyItem> ();
                        float      baseValue  = 0;
                        if (energyItem != null)
                        {
                            baseValue        = energyItem.Value;
                            energyItem.Value = resValue;
                        }
                        MassItem massItem = item.GetComponent <MassItem> ();
                        if (massItem != null)
                        {
                            baseValue      = massItem.Value;
                            massItem.Value = resValue;
                        }

                        item.transform.localScale = item.transform.localScale * resValue / baseValue;
                        item.transform.position   = gameObject.transform.position + new Vector3(Random.Range(-1 * pieceRange, 1 * pieceRange), 0, Random.Range(-1 * pieceRange, 1 * pieceRange));
                        item.transform.SetParent(GameControl.Instance.bombItemsHolder.transform, true);
                    }
                    return(true);
                }
                else
                {
                    pieceNum--;
                }
            }
        }

        return(false);
    }
Exemple #5
0
 void Awake()
 {
     _rb       = GetComponent <Rigidbody>();
     _massItem = GetComponent <MassItem>();
     _massItem.onValueChangedCallBack += OnMassItemValueChanged;
 }