コード例 #1
0
        public Color4 getColor(ElementColor elementType, float alpha)
        {
            Color4 col = colors[(int)elementType];

            col.A = alpha;
            return(col);
        }
コード例 #2
0
ファイル: Element.cs プロジェクト: timzaykin/Test
    public static Color GetColor(ElementColor _color)
    {
        switch (_color)
        {
        case ElementColor.red:
            return(Color.red);

        case ElementColor.orange:
            return(new Color(1, 0.35f, 0));

        case ElementColor.yellow:
            return(Color.yellow);

        case ElementColor.green:
            return(Color.green);

        case ElementColor.lightBlue:
            return(new Color(0, 1, 1));

        case ElementColor.blue:
            return(Color.blue);

        case ElementColor.violet:
            return(Color.magenta);

        default:
            return(Color.white);
        }
    }
コード例 #3
0
ファイル: ColorChanger.cs プロジェクト: manuel2258/timed
 public ColorChanger(Position pos, ElementColor color, float size = 0) : base(ElementType.ColorChanger, posRadius)
 {
     positionX         = pos.x;
     positionY         = pos.y;
     this.initialColor = color;
     colors            = new List <ElementColor>();
 }
コード例 #4
0
 public Goal(Position pos, int counter, ElementColor color) : base(ElementType.Goal, posRadius)
 {
     positionX    = pos.x;
     positionY    = pos.y;
     this.counter = counter;
     this.color   = color;
 }
コード例 #5
0
ファイル: Randoms.cs プロジェクト: manuel2258/timed
        public static ElementColor getColor(List <ElementColor> excludedColors)
        {
            List <int>   intColors = new List <int>();
            ElementColor selColor  = 0;

            for (int i = (int)ElementColor._first_ + 1; i <= (int)ElementColor._last_ - 1; i++)
            {
                bool bAdd = true;
                foreach (ElementColor color in excludedColors)
                {
                    if ((int)color == i)
                    {
                        bAdd = false;
                        break;
                    }
                }
                if (bAdd)
                {
                    intColors.Add(i);
                }
            }

            if (intColors.Count > 0)
            {
                int idx = getInt(0, intColors.Count - 1);
                selColor = (ElementColor)intColors[idx];
            }
            else
            {
                throw new Exception("getColor: no colour available");
            }

            return(selColor);
        }
コード例 #6
0
 public RadialGravityState(RadialGravityState that)
 {
     force              = that.force;
     enabled            = that.enabled;
     color              = that.color;
     colliderBodyInside = that.colliderBodyInside;
 }
コード例 #7
0
        public static GameElement CreateGameElementWithParameters(Grid parent, ElementColor color, BonusType type = BonusType.None)
        {
            var element = new GameElement(color, parent);

            element.BonusType = type;
            return(element);
        }
コード例 #8
0
    private IEnumerable <int> LeftSort()
    {
        wasSorted = false;
        int offset  = 0;
        int offsetA = 0;

        for (int i = 0 + rightCounter + leftOffsetStart; i < Array.Count - 1 - leftOffsetEnd - leftCounter; i++)
        {
            offsetA++;
            if (Array[i] > Array[i + 1])
            {
                offsetA   = 0;
                wasSorted = true;
                int tmpVal = Array[i];
                Array[i]     = Array[i + 1];
                Array[i + 1] = tmpVal;
                RelocateElements(i + 1, i);
            }
            if (!wasSorted)
            {
                offset++;
            }

            CompareElements(true,
                            ElementColor.Build(i, Color.red),
                            ElementColor.Build(i + 1, Color.red));
            yield return(i);
        }

        leftCounter++;
        leftOffsetStart += offset - 1;
        leftOffsetEnd   += offsetA;
    }
コード例 #9
0
    private IEnumerable <int> RightSort()
    {
        wasSorted = false;
        int offset  = 0;
        int offsetA = 0;

        for (int i = Array.Count - 1 - rightOffsetStart - leftCounter; i > 0 + rightOffsetEnd + rightCounter; i--)
        {
            offsetA++;
            if (Array[i] < Array[i - 1])
            {
                offsetA   = 0;
                wasSorted = true;
                int tmpVal = Array[i];
                Array[i]     = Array[i - 1];
                Array[i - 1] = tmpVal;
                RelocateElements(i - 1, i);
            }
            if (!wasSorted)
            {
                offset++;
            }

            CompareElements(true,
                            ElementColor.Build(i, Color.red),
                            ElementColor.Build(i - 1, Color.red));
            yield return(i);
        }

        rightCounter++;
        rightOffsetStart += offset - 1;
        rightOffsetEnd   += offsetA;
    }
コード例 #10
0
        private bool findRadialGravity(Position pos, float radius, ElementColor color)
        {
            foreach (Element elem in elementsTimeLine[timeStep])
            {
                if (elem.type == ElementType.RadialGravity)
                {
                    float dist = LevelHelper.getDistance(pos, elem.getPosition());
                    if (dist < radius)
                    {
                        RadialGravity rg = (RadialGravity)elem;
                        if (rg.containsColor(color))
                        {
                            return(true);
                        }
                        else
                        {
                            // add color to existing RadialGravity
                            elementsTimeLine[timeStep].Remove(rg);
                            List <ElementColor> colors = new List <ElementColor>();
                            colors.Add(rg.colors[0]);
                            colors.Add(color);
                            RadialGravity rgNew = new RadialGravity(rg.getPosition(), rg.strength, rg.strengthRadius, colors, rg.id);
                            elementsTimeLine[timeStep].Add(rgNew);
                            return(true);
                        }
                    }
                }
            }

            return(false);
        }
コード例 #11
0
    public override IEnumerable <int> Sort()
    {
        for (int i = 0; i < Array.Count; i++)
        {
            bool isSorted = true;
            for (int a = 0; a < Array.Count - i - 1; a++)
            {
                if (Array[a] > Array[a + 1])
                {
                    int tmp = Array[a];
                    Array[a]     = Array[a + 1];
                    Array[a + 1] = tmp;
                    RelocateElements(a, a + 1);
                    isSorted = false;
                }
                CompareElements(true,
                                ElementColor.Build(a, Color.red),
                                ElementColor.Build(a + 1, Color.red));
                yield return(i);
            }

            if (isSorted)
            {
                FinishSorting();
                yield break;
            }
        }
        FinishSorting();
    }
コード例 #12
0
 private void ChangeSample()
 {
     sampleFigure = (Figure)Random.Range(0, 3);
     sampleColor  = (ElementColor)Random.Range(0, 7);
     UIManager.Instance.SetSampleFigure(sampleFigure, sampleColor);
     //Debug.Log(sampleFigure.ToString() + "   " + sampleColor.ToString());
 }
コード例 #13
0
    static public ElementColor Build(int index, Color color)
    {
        ElementColor elementColor = new ElementColor()
        {
            elementColor = color,
            elementInxe  = index
        };

        return(elementColor);
    }
コード例 #14
0
ファイル: RadialGravity.cs プロジェクト: manuel2258/timed
        public bool containsColor(ElementColor color)
        {
            foreach (ElementColor c in colors)
            {
                if (c == color)
                {
                    return(true);
                }
            }

            return(false);
        }
コード例 #15
0
    public override IEnumerable <int> Sort()
    {
        for (int i = 1; i < Array.Count; i++)
        {
            if (Array[i] >= Array[i - 1])
            {
                continue;
            }
            CompareElements(true, ElementColor.Build(i, Color.green));
            yield return(i);

            min = 0;
            max = i;

            while (min <= max)
            {
                int key = Array[i];
                int mid = (min + max) / 2;
                CompareElements(true,
                                ElementColor.Build(i, Color.green),
                                ElementColor.Build(mid, Color.red));
                yield return(i);

                if (mid == 0 && key <= Array[mid])
                {
                    ShiftArray(mid, i, Array);
                    break;
                }
                if (key <= Array[mid + 1] && key >= Array[mid])
                {
                    ShiftArray(++mid, i, Array);
                    break;
                }
                else if (key < Array[mid])
                {
                    max = mid - 1;
                }
                else
                {
                    min = mid + 1;
                }
            }
        }

        FinishSorting();
    }
コード例 #16
0
        private void AddGravity(Position pos, ElementColor color)
        {
            if (findRadialGravity(pos, RadialGravity.forceRadius, color))
            {
                return;
            }

            Position posRG    = Randoms.getPositionInCircle(pos, RadialGravity.forceRadius);
            float    strength = GravityForce.force[Randoms.getInt(0, 2)];

            RadialGravity rg = new RadialGravity(posRG, strength, RadialGravity.forceRadius, new List <ElementColor>()
            {
                color
            });

            elementsTimeLine[timeStep].Add(rg);
        }
コード例 #17
0
        protected void ChooseEvent()
        {
            int cnt = eventCandidates.Count;
            int rdx = Randoms.getInt(0, cnt - 1);
            int id  = eventCandidates[rdx];

            Element elem = getElement(timeStep, id);

            switch (elem.type)
            {
            case ElementType.Goal:
                Goal goal = (Goal)elem;
                goal.counterTimed++;
                Position newPos = getFreePosition(ColliderBody.posRadius, goal.getPosition(),
                                                  RadialGravity.forceRadius);
                ColliderBody colliderBody = new ColliderBody(newPos, goal.color);
                elementsTimeLine[timeStep].Add(colliderBody);

                eventsTimeLine.Add(new TimeLineEvent(colliderBody.id, goal.id));

                AddGravity(newPos, goal.color);
                break;

            case ElementType.ColliderBody:
                ColliderBody coll     = (ColliderBody)elem;
                ElementColor oldColor = coll.color;
                Position     oldPos   = new Position(coll.positionX, coll.positionY);
                ColorChanger chg      = new ColorChanger(oldPos, oldColor);
                elementsTimeLine[timeStep].Add(chg);

                elementsTimeLine[timeStep].Remove(coll);
                Position     newPosColl = getFreePosition(ColliderBody.posRadius, oldPos, RadialGravity.forceRadius);
                ElementColor newColor   = Randoms.getColor(new List <ElementColor>()
                {
                    oldColor
                });
                ColliderBody newColl = new ColliderBody(newPosColl, newColor, coll.id);
                elementsTimeLine[timeStep].Add(newColl);

                eventsTimeLine.Add(new TimeLineEvent(coll.id, chg.id));

                AddGravity(newPosColl, newColor);
                break;
            }
        }
コード例 #18
0
        public static Color32 getColorValue(ElementColor color)
        {
            switch (color)
            {
            case ElementColor.Yellow:
                return(new Color32(255, 255, 0, 255));

            case ElementColor.Blue:
                return(new Color32(0, 255, 255, 255));

            /*case ElementColor.Green:
             *  return new Color32(0, 255, 0, 255);
             * case ElementColor.Red:
             *  return new Color32(255,0,0, 255);*/
            default:
                return(Color.black);
            }
        }
コード例 #19
0
        private void AddGravity(Position pos1, Position pos2, ElementColor color)
        {
            Position center         = LevelHelper.getCenter(pos1, pos2);
            float    radius         = LevelHelper.getDistance(pos1, pos2) * factorRadiusGravity;
            Position posRG          = Randoms.getPositionInCircle(center, radius);
            float    dist1          = LevelHelper.getDistance(pos1, posRG);
            float    dist2          = LevelHelper.getDistance(pos2, posRG);
            float    dist           = Math.Max(dist1, dist2);
            float    strength       = GravityForce.getForce(dist);
            float    strengthRadius = GravityForce.getForceRadius(strength);

            RadialGravity rg = new RadialGravity(posRG, strength, strengthRadius, new List <ElementColor>()
            {
                color
            });

            elementsTimeLine[timeStep].Add(rg);
        }
コード例 #20
0
ファイル: Game.cs プロジェクト: pavelmx/RunCube
    void ResetGame()
    {
        fullscreenOverlayTexture.enabled = false;

        actualBlockOffset   = 0;
        actualBlockWidth    = 0;
        activeBuildingIndex = 0;
        activeBlockIndex    = 0;

        actualBlockMinBuildingWidth            = 18;
        actualBlockMaxBuildingWidth            = 20;
        actualBlockMinSpaceWidth               = 1.4f;
        actualBlockMaxSpaceWidth               = 1.6f;
        actualBlockMaxBuildingGroundDifference = 0.5f;
        lastBuildingGround = 0.0f;

        CreateNewBlock();
        CreateNewBlock();

        avatarColor = oldBlockBuildingColors[0];
        if (avatarColor == ElementColor.Green)
        {
            avatarMeshRenderer.material  = greenMaterial;
            avatarTrailRenderer.material = greenMaterial;
        }
        else
        {
            avatarMeshRenderer.material  = redMaterial;
            avatarTrailRenderer.material = redMaterial;
        }

        avatarSpeed      = kStartAvatarSpeed;
        jumpEnergy       = kStartingJumpEnergy;
        readyForNextJump = true;

        avatarRigidBody.isKinematic = true;
        avatar.transform.rotation   = Quaternion.identity;
        avatar.position             = new Vector3(1.0f, 1.5f, 0.0f);

        transform.position = new Vector3(8.0f, 1.2f, -30.0f);

        gameState = GameState.Playing;
    }
コード例 #21
0
        private void CreateGoals(int difficulty)
        {
            // Goals
            elementsTimeLine.Add(new List <Element>());
            int cntGoals = 1 + Math.Min((int)ElementColor._last_ - 2, (difficulty / 3));
            List <ElementColor> colors = new List <ElementColor>();

            for (int i = 1; i <= cntGoals; i++)
            {
                int          counter = Randoms.getInt(1, difficulty);
                ElementColor color   = Randoms.getColor(colors);
                colors.Add(color);
                Position pos  = getFreePosition(Goal.posRadius);
                Goal     goal = new Goal(pos, counter, color);
                elementsTimeLine[timeStep].Add(goal);
            }

            // Dummy Event
            eventsTimeLine.Add(new TimeLineEvent(0, 0));
        }
コード例 #22
0
        public void setup(string color, string amount)
        {
            onSetup();
            _color = ParseHelper.getElementColorFromString(color);

            _currentState = new GoalState();

            if (!int.TryParse(amount, out _currentState.remainingAmount))
            {
                throw new Exception("GoalTrigger: Could not parse amount argument -> " + amount);
            }

            if (GlobalGameState.Instance.IsInGame)
            {
                LevelFinishManager.Instance.registerGoal(this);
            }

            _initialState = new GoalState(_currentState);
            setVisualsByState(_currentState);
        }
コード例 #23
0
        public static bool button(String s, Vector2 size)
        {
            Window win = currentWindow;

            if (win.skipItems)
            {
                return(false);
            }

            UInt32  id        = win.getChildId(s);
            Vector2 labelSize = style.textSize(s);

            //move cursor down for the size of the text accounting for the padding
            Vector2 pos = win.cursorScreenPosition + style.framePadding;
            Rect    r   = Rect.fromPosSize(pos, size);

            bool hovered;
            bool held;
            bool pressed = buttonBehavior(r, id, out hovered, out held);

            ElementColor useColor = (hovered && held) ? ElementColor.ButtonActive : (hovered ? ElementColor.ButtonHovered : ElementColor.Button);
            Color4       col      = style.colors[(int)useColor];

            //draw the thing
            style.pushStyleVar(StyleVar.FrameRounding, 9.0f);
            win.canvas.addRectFilled(r, col, style.frameRounding);
            win.canvas.addRect(r, style.colors[(int)ElementColor.Border], style.frameRounding);

            //center text in button
            win.canvas.pushClipRect(r);
            win.canvas.addText(r, style.colors[(int)ElementColor.Text], s, Alignment.Middle);

            //cleanup
            win.canvas.popClipRect();
            style.popStyleVar(1);

            //update the window cursor
            win.addItem(size);

            return(pressed);
        }
コード例 #24
0
    private IEnumerable <int> SortChunk(int startIndex, int endIndex)
    {
        int median      = GetMedianSimple(startIndex, endIndex);
        int rightOffset = 0;

        for (int i = startIndex; i < endIndex - rightOffset; i++)
        {
            CompareElements(true,
                            ElementColor.Build(endIndex, Color.blue),
                            ElementColor.Build(startIndex, Color.blue),
                            ElementColor.Build(i, Color.green));

            if (Array[i] >= median)
            {
                for (int a = endIndex - rightOffset; a > i; a--)
                {
                    CompareElements(true,
                                    ElementColor.Build(i, Color.green),
                                    ElementColor.Build(a, Color.red),
                                    ElementColor.Build(endIndex, Color.blue),
                                    ElementColor.Build(startIndex, Color.blue));

                    rightOffset++;
                    if (Array[a] < median)
                    {
                        SwapElements(i, a);
                        //yield return a;
                        break;
                    }

                    yield return(a);
                }
            }

            yield return(i);
        }
    }
コード例 #25
0
    public override IEnumerable <int> Sort()
    {
        for (int i = 1; i < Array.Count; i++)
        {
            if (Array[i] >= Array[i - 1])
            {
                continue;
            }
            CompareElements(true,
                            ElementColor.Build(i, Color.green),
                            ElementColor.Build(i - 1, Color.red));
            yield return(i);

            for (int a = i; a > 0; a--)
            {
                int b = a - 1;
                CompareElements(true,
                                ElementColor.Build(i, Color.green),
                                ElementColor.Build(b, Color.red));
                yield return(a);

                if (Array[i] >= Array[b])
                {
                    ShiftArray(b + 1, i, Array);
                    break;
                }
                else if (b == 0)
                {
                    ShiftArray(b, i, Array);
                    break;
                }
            }
        }

        FinishSorting();
    }
コード例 #26
0
 public Color4 getColor(ElementColor elementType)
 {
     return(colors[(int)elementType]);
 }
コード例 #27
0
 public ColorChangerState(ColorChangerState that)
 {
     color = that.color;
 }
コード例 #28
0
ファイル: Element.cs プロジェクト: tobster-de/WebColumns
 /// <summary>
 /// Konstruktor
 /// </summary>
 /// <param name="color">Farbe des Elements</param>
 /// <param name="x">Position X-Koordinate</param>
 /// <param name="y">Position Y-Koodinate</param>
 public Element(ElementColor color, int x, int y)
 {
     _location = new Location(x, y);
     Color = color;
 }
コード例 #29
0
 public ColliderBody(Position pos, ElementColor color, int id) : base(ElementType.ColliderBody, posRadius, id)
 {
     positionX  = pos.x;
     positionY  = pos.y;
     this.color = color;
 }
コード例 #30
0
 private Data <T> FilterByColor(ElementColor color)
 {
     return(new Data <T>(from x in list where x.Color == color select x));
 }
コード例 #31
0
 public TeleporterState(TeleporterState that)
 {
     enabled = that.enabled;
     color   = that.color;
 }