void ChangeIndicatorColors(RingData data)
 {
     if (data.Outer)
     {
         firstColor.color = ColorManager.instance.FetchColorInformation(data.ringColors[0]);
     }
     else
     {
         firstColor.color = inactiveIndicatorColor;
     }
     if (data.Middle)
     {
         secondColor.color = ColorManager.instance.FetchColorInformation(data.ringColors[1]);
     }
     else
     {
         secondColor.color = inactiveIndicatorColor;
     }
     if (data.Inner)
     {
         thirdColor.color = ColorManager.instance.FetchColorInformation(data.ringColors[2]);
     }
     else
     {
         thirdColor.color = inactiveIndicatorColor;
     }
 }
Exemplo n.º 2
0
    public void SpawnRingDataAtRandomPoint(RingData ringData)
    {
        List <ReferencePointBehaviour> availablePoints = new List <ReferencePointBehaviour>();

        foreach (ReferencePointBehaviour node in TransformationGrid.NODES)
        {
            //Debug.Log("CHECK");
            if (!node.HaveRing())
            {
                //Debug.Log("ADD NODE");
                availablePoints.Add(node);
            }
        }
        if (availablePoints.Count > 0)
        {
            if (RingFactoryComponent != null)
            {
                //Debug.Log("Available Points: "+availablePoints.Count);
                RingFactoryComponent.SpawnRingDataAtPoint(ringData, availablePoints[UnityEngine.Random.Range(0, availablePoints.Count - 1)]);
            }
        }
        else
        {
            Lose();
        }
    }
Exemplo n.º 3
0
    public void RemoveColor(ColorIndex index)
    {
        RingData newState = currentRingData;

        for (int i = 0; i < newState.ringColors.Count; i++)
        {
            if (newState.ringColors[i] == index)
            {
                //TODO Add implementation to count color remove over here
                newState.ringColors[i] = ColorIndex.NONE;
            }
        }
        if (newState.ringColors[0] == ColorIndex.NONE)
        {
            newState.Outer = false;
        }
        if (newState.ringColors[1] == ColorIndex.NONE)
        {
            newState.Middle = false;
        }
        if (newState.ringColors[2] == ColorIndex.NONE)
        {
            newState.Inner = false;
        }
        CurrentRingData = newState;
    }
Exemplo n.º 4
0
    public bool CheckIfCanCombine(RingData other)
    {
        bool conflict = false;

        #region TIER CHECKS
        // OUTER
        if (currentRingData.Outer)
        {
            if (other.Outer)
            {
                conflict = true;
            }
        }
        // MIDDLE
        if (currentRingData.Middle)
        {
            if (other.Middle)
            {
                conflict = true;
            }
        }

        // INNER
        if (currentRingData.Inner)
        {
            if (other.Inner)
            {
                conflict = true;
            }
        }
        #endregion
        return(conflict);
    }
Exemplo n.º 5
0
    public void SpawnRingDataAtPoint(RingData ringData, ReferencePointBehaviour point)
    {
        GameObject    ring          = Instantiate(RingPrefab);
        RingBehaviour ringComponent = ring.GetComponent <RingBehaviour>();

        ringComponent.CurrentRingData = ringData;

        point.GetComponent <RingPointManager>().AcceptSpawnedRing(ringComponent);
    }
Exemplo n.º 6
0
 public bool CheckPointIfCanAccept(RingData other)
 {
     if (ring)
     {
         return(ring.CheckIfCanCombine(other));
     }
     else
     {
         return(true);
     }
 }
Exemplo n.º 7
0
    public void RemoveRing()
    {
        RingData newState = new RingData();

        newState.ringColors = new List <ColorIndex>();
        for (int i = 0; i < 2; i++)
        {
            newState.ringColors.Add(ColorIndex.NONE);
        }
        CurrentRingData = newState;
    }
Exemplo n.º 8
0
    public bool CombineRings(RingData other)
    {
        // Return true if can combine, else return false.
        // This function is called on the Ring that is attached to the reference point.
        // not on the currently selected one.
        bool     conflict = false;
        RingData newState = currentRingData;

        #region TIER CHECKS
        // OUTER
        if (!currentRingData.Outer)
        {
            newState.Outer         = other.Outer;
            newState.ringColors[0] = other.ringColors[0];
        }
        else if (other.Outer)
        {
            conflict = true;
        }
        // MIDDLE
        if (!currentRingData.Middle)
        {
            newState.Middle        = other.Middle;
            newState.ringColors[1] = other.ringColors[1];
        }
        else if (other.Middle)
        {
            conflict = true;
        }
        // INNER
        if (!currentRingData.Inner)
        {
            newState.Inner         = other.Inner;
            newState.ringColors[2] = other.ringColors[2];
        }
        else if (other.Inner)
        {
            conflict = true;
        }
        #endregion
        if (conflict)
        {
            //Debug.Log("CANNOT COMBINE :<");
            return(false);
        }
        else
        {
            //Debug.Log("CAN COMBINE!");
            currentRingData = newState;
            PaintRings();
            stateChangeEvent();
            return(true);
        }
    }
Exemplo n.º 9
0
 public void onAnomalyEvent()
 {
     if (targetReferencePointToSpawnWhenStagingSetUpdate == null)
     {
         List <ReferencePointBehaviour> availablePoints = new List <ReferencePointBehaviour>();
         foreach (ReferencePointBehaviour node in TransformationGrid.NODES)
         {
             //Debug.Log("CHECK");
             if (!node.HaveRing())
             {
                 //Debug.Log("ADD NODE");
                 availablePoints.Add(node);
             }
         }
         if (availablePoints.Count > 0)
         {
             TargetReferencePointToSpawnWhenStagingSetUpdate = availablePoints[UnityEngine.Random.Range(0, availablePoints.Count - 1)];
         }
         else
         {
             TargetReferencePointToSpawnWhenStagingSetUpdateChange = null;
             return;
         }
         RingDataToSpawnWhenStagingSetUpdate           = RingFactoryComponent.GenerateNewRingData();
         RingDataToSpawnWhenStagingSetUpdate.spawnType = SpawnType.Anomaly; // Add a modifier to the ringdata class so matchcontroller will catch it.
     }
     else
     {
         if (!targetReferencePointToSpawnWhenStagingSetUpdate.HaveRing())
         {
             RingFactoryComponent.SpawnRingDataAtPoint(RingDataToSpawnWhenStagingSetUpdate, targetReferencePointToSpawnWhenStagingSetUpdate);
             if (AnomalyEventSuccess != null)
             {
                 AnomalyEventSuccess();
             }
         }
         else
         {
             if (AnomalyEventFail != null)
             {
                 AnomalyEventFail();
             }
         }
         TargetReferencePointToSpawnWhenStagingSetUpdate = null;
         RingDataToSpawnWhenStagingSetUpdate             = new RingData();
     }
 }
Exemplo n.º 10
0
    public RingData GenerateNewRingData()
    {
        RingData data = new RingData();

        data.Inner  = Random.value < 0.5 ? true : false;
        data.Middle = Random.value < 0.5 ? true : false;
        data.Outer  = Random.value < 0.5 ? true : false;
        #region EDGE CASES
        if (!(data.Inner && data.Middle && data.Outer))
        {
            float chance = Random.value;
            if (chance < 0.33)
            {
                data.Inner = true;
            }
            else if (chance < 0.66)
            {
                data.Middle = true;
            }
            else
            {
                data.Outer = true;
            }
        }
        if (data.Inner && data.Middle && data.Outer)
        {
            float chance = Random.value;
            if (chance < 0.33f)
            {
                data.Inner = false;
            }
            else if (chance < 0.66f)
            {
                data.Middle = false;
            }
            else
            {
                data.Outer = false;
            }
        }
        #endregion
        //TODO Address case when adjacent tiers have the same color (not important but good to have)
        data.ringColors = new List <ColorIndex>();
        for (int i = 0; i < 3; i++)
        {
            ColorIndex clr = ColorManager.instance.FetchColorIndex();
            //Debug.Log(clr);
            data.ringColors.Add(clr);
        }
        if (!data.Outer)
        {
            data.ringColors[0] = ColorIndex.NONE;
        }
        if (!data.Middle)
        {
            data.ringColors[1] = ColorIndex.NONE;
        }
        if (!data.Inner)
        {
            data.ringColors[2] = ColorIndex.NONE;
        }
        return(data);
    }
Exemplo n.º 11
0
    private static RingData loadRing(StreamReader reader)
    {
        RingData rd = new RingData();
        string   line;

        do
        {
            line = reader.ReadLine();
            if (line != null)
            {
                line = line.Trim();
                string[] entries = line.Split(' ');
                if (entries[0] == "tick")                 //new tick behaviour
                {
                    Type t;
                    if (ticks.TryGetValue(entries[1], out t))
                    {
                        SegmentTickBehaviour stb = makeInstance(t, entries.Skip(2).ToArray()) as SegmentTickBehaviour;
                        if (stb != null)
                        {
                            rd.segmentTickBehaviours.Add(stb);
                        }
                    }
                }
                else if (entries[0] == "trigger")                  //new trigger behaviour
                {
                    Type t;
                    if (triggers.TryGetValue(entries[1], out t))
                    {
                        SegmentTriggerBehaviour stb = makeInstance(t, entries.Skip(2).ToArray()) as SegmentTriggerBehaviour;
                        if (stb != null)
                        {
                            rd.segmentTriggerBehaviours.Add(stb);
                        }
                    }
                }
                else if (entries[0] == "collision")                  //new collision behaviour
                {
                    Type t;
                    if (collisions.TryGetValue(entries[1], out t))
                    {
                        SegmentCollisionBehaviour scb = makeInstance(t, entries.Skip(2).ToArray()) as SegmentCollisionBehaviour;
                        if (scb != null)
                        {
                            rd.segmentCollisionBehaviours.Add(scb);
                        }
                    }
                }
                else if (entries[0] == "sprite")                  //new sprite
                {
                    Sprite s;
                    if (sprites.TryGetValue(entries[1], out s))
                    {
                        rd.sprite = s;
                    }
                }
                else if (entries[0] == "size")
                {
                    rd.size = float.Parse(entries[1]);
                }
                else if (entries[0] == "end")
                {
                    return(rd);
                }
            }
        } while (line != null);
        return(rd);
    }