示例#1
0
 private void OnArrowTaken(ArrowData arrow)
 {
     if (Properties.Settings.Default.AutoAddToHistory)
     {
         AddArrow(arrow);
     }
 }
示例#2
0
 public void AddArrow(ArrowData arrow)
 {
     if (arrow.BasicTestDone && currentSet.Contains(arrow) == false)
     {
         currentSet.AddArrow(arrow);
         AddArrowToView(arrow);
     }
 }
    void Awake()
    {
        arrows = new List <ArrowData>();
        GameObject[] _arrows = GameObject.FindGameObjectsWithTag("GravityIndicator");

        foreach (var arrow in _arrows)
        {
            ArrowData newArrowData = new ArrowData(arrow);
            arrows.Add(newArrowData);
        }
    }
        private void LateUpdate()
        {
            if (_linkedPart != null && _linkedPart.vessel.staticPressurekPa > 0f)
            {
                _centerOfLift = FindCenterOfLift(_linkedPart.vessel.rootPart, _linkedPart.vessel.srf_velocity, _linkedPart.vessel.altitude,
                                                 _linkedPart.vessel.staticPressurekPa, _linkedPart.vessel.atmDensity);

                transform.position = _centerOfLift.Position;
                transform.rotation = _linkedPart.vessel.transform.rotation;
            }
        }
示例#5
0
        public static ElementTag BuildArrow(IEntityManager manager, ArrowData data)
        {
            var geo = GeometryBuilder.BuildArrow(data);

            return(manager
                   .CreateEntity(data.tag)
                   .AddComponent(geo)
                   .AddComponent(D3DTriangleColoredVertexRenderComponent.AsStrip())
                   .AddComponent(new TransformComponent())
                   .Tag);
        }
        public void AddReport(List <FrameworkElement> elementList, ReportType rType, string strMsg)
        {
            StackPanel usedStackPanel = null;
            GroupBox   usedGroupBox   = null;
            Brush      brush          = null;
            string     postString     = "";

            switch (rType)
            {
            case ReportType.Error:
                usedStackPanel = ErrorStackPanel;
                brush          = Brushes.Red;
                postString     = "错误";
                usedGroupBox   = ErrorGroupBox;
                break;

            case ReportType.Warning:
                usedStackPanel = WarningStackPanel;
                brush          = Brushes.Yellow;
                postString     = "警告";
                usedGroupBox   = WarningGroupBox;
                break;
            }

            if (usedGroupBox.Visibility != Visibility.Visible)
            {
                usedGroupBox.Visibility = Visibility.Visible;
            }

            Label lInfo = new Label()
            {
                Content         = strMsg,
                Margin          = new Thickness(2, 2, 2, 2),
                Foreground      = brush,
                BorderThickness = new Thickness(1),
                BorderBrush     = brush,
                Background      = new System.Windows.Media.SolidColorBrush(Color.FromArgb(100, 0, 0, 0))
            };

            usedStackPanel.Children.Add(lInfo);
            usedGroupBox.Header = usedStackPanel.Children.Count.ToString() + "个" + postString;

            foreach (var element in elementList)
            {
                if (element == null)
                {
                    continue;
                }
                ArrowData arData = new ArrowData(m_parentCanvas, lInfo, element, brush);
                m_arrowList.Add(arData);
            }

            UpdateArrow();
        }
示例#7
0
 private void AddArrowToView(ArrowData arrow)
 {
     if (historyView.InvokeRequired)
     {
         var d = new Action <ArrowData>(AddArrowToView);
         Invoke(d, new object[] { arrow });
     }
     else
     {
         historyView.Rows.Add(arrow.ToArray());
     }
 }
示例#8
0
    // when an arrow is pressed and released, shift a column up/down or a row right/left
    public void ArrowButtonReleased(FButton button)
    {
        ArrowData arrowData = (ArrowData)button.data;

        if (arrowData.direction == Direction.Up || arrowData.direction == Direction.Down)
        {
            ShiftColumnInDirection(arrowData.index, arrowData.direction);
        }

        else if (arrowData.direction == Direction.Right || arrowData.direction == Direction.Left)
        {
            ShiftRowInDirection(arrowData.index, arrowData.direction);
        }
    }
示例#9
0
        public static ArrowGameObject Build(IEntityManager manager, ArrowData data)
        {
            var geo = GeometryBuilder.BuildArrow(data);

            geo.Color = data.color;
            var en = manager
                     .CreateEntity(data.tag)
                     .AddComponents(
                geo,
                D3DTriangleColoredVertexRenderComponent.AsStrip(),
                new TransformComponent()
                );

            return(new ArrowGameObject(en.Tag));
        }
示例#10
0
    void Update()
    {
        if (timer > 0)
        {
            timer -= Time.deltaTime;
        }
        else
        {
            if (arrowQueue.Count > 0)
            {
                ArrowData a = arrowQueue.Dequeue();

                timer = a.time;

                GameObject o = this.GetFromPool();
                SetParams(o, a.speed, a.dir, zones[(int)a.dir]);
            }
        }
    }
示例#11
0
    int visitedAmount;            // to check if visited all

    // -----------------------------------------------
    // For gameplay >>>>>>

    public void resetAll()
    {
        playVisited        = 0;
        lastPressed        = null;
        lastPressedTintObj = null;

        var arrows = GameObject.FindGameObjectsWithTag("ArrowItem");

        // loops through all arrowItems
        foreach (var arrowItem in arrows)
        {
            ArrowData dataHolder = arrowItem.GetComponent <ArrowData>();
            if (dataHolder.activated)
            {
                arrowItem.GetComponent <UpdateTint>().setShrink(0.6f);
                dataHolder.activated = false;
            }
        }
    }
示例#12
0
        public static ArrowGameObject Create(IContextState context, ElementTag tag, ArrowData data, bool visible = true)
        {
            var geo = GeometryBuilder.BuildArrow(data);

            var geoId = context.GetGeometryPool()
                        .AddGeometry(geo);

            var en = context.GetEntityManager()
                     .CreateEntity(tag)
                     .AddComponent(visible ?
                                   RenderableComponent.AsTriangleColored(SharpDX.Direct3D.PrimitiveTopology.TriangleStrip)
                : RenderableComponent.AsTriangleColored(SharpDX.Direct3D.PrimitiveTopology.TriangleStrip).Disable())
                     .AddComponent(TransformComponent.Identity())
                     .AddComponent(MaterialColorComponent.Create(data.color))
                     .AddComponent(geoId)
            ;

            return(new ArrowGameObject(en.Tag));
        }
示例#13
0
        public void LoadFromXML(XDocument doc)
        {
            foreach (var a in doc.Root.Attributes())
            {
                switch (a.Name.LocalName)
                {
                case "rating":
                    Rating = Convert.ToInt32(a.Value);
                    break;

                case "description":
                    Description = a.Value;
                    break;

                case "style":
                    Style = a.Value;
                    break;

                case "difficulty":
                    Difficulty = a.Value;
                    break;
                }
            }

            foreach (var e in doc.Root.Elements())
            {
                if (e.Name.LocalName == "stepdata")
                {
                    foreach (var x in e.Elements())
                    {
                        ArrowData.Add(e.ToArrow());
                    }
                }
                else if (e.Name.LocalName == "freezedata")
                {
                    foreach (var x in e.Elements())
                    {
                        FreezeData.Add(e.ToArrow());
                    }
                }
            }
        }
示例#14
0
        private string[] GetDataString(ArrowData a, bool full = false)
        {
            var s = new List <string>
            {
                a.Index.ToString(),
                a.Weight.Grams.ToString("0.0"),
                a.Weight.Grains.ToString(),
                a.Spine.AMO.ToString(),
                a.Spine.ASTM.ToString(),
                a.Straightness.String
            };

            if (full)
            {
                s.Add(a.Spine.AMO1.ToString());
                s.Add(a.Spine.ASTM1.ToString());
                s.Add(a.Spine.AMO2.ToString());
                s.Add(a.Spine.ASTM2.ToString());
            }

            return(s.ToArray());
        }
示例#15
0
    // Update is called once per frame
    void Update()
    {
        if (timer)
        {
            if (_time < waitTime)
            {
                _time += Time.deltaTime;

                playerColor.a = (waitTime - _time) / waitTime;

                arrow1.GetComponent <Renderer>().material.color = playerColor;
                arrow2.GetComponent <Renderer>().material.color = playerColor;
            }
            else
            {
                userInput = directions[UnityEngine.Random.Range(0, 2)];
                clicked   = true;
            }

            if (clicked && NetworkClient.serverObjects[NetworkClient.ClientID].IsMyTurn())
            {
                timer = false;
                _time = 0;

                if (userInput == -1)
                {
                    Debug.Log("error : direction not selected");
                }
                else
                {
                    Debug.Log("emit selectDirection");
                    ArrowData returnData = new ArrowData();
                    returnData.selectedDIR = (int)userInput;
                    client.GetSocket().Emit("selectDirection", new JSONObject(JsonUtility.ToJson(returnData)));
                }
            }
        }
    }
示例#16
0
        public GameObject DrawArrow(string key, ArrowDetails arrowData)
        {
            var llength = 10;

            var tt = new ArrowData {
                axis       = arrowData.Axis,
                orthogonal = arrowData.Orthogonal,
                center     = arrowData.Center + arrowData.Axis * (llength - 2),
                lenght     = 2.1f,
                radius     = .8f,
                color      = arrowData.Color
            };

            var points = new[] {
                arrowData.Center, arrowData.Center + arrowData.Axis * llength,
            };

            var arrow = ArrowGameObject.Create(Context, ElementTag.New($"{key}_arrowhead"), tt);

            var line = VisualPolylineObject.Create(Context, ElementTag.New($"{key}_arrowline"),
                                                   points, arrowData.Color, true);

            return(new MultiVisualObject(new[] { arrow.Tag, line.Tag }, key));
        }
示例#17
0
    public void Execute(int index)
    {
        var t      = transforms[index];
        var archer = archers[index];

        // check if closest formation exists
        var closestFormationEntity = closestFormationsFromEntity[t.FormationEntity].closestFormation;

        if (closestFormationEntity == new Entity())
        {
            return;
        }

        // Check the distance
        var closestFormation = formations[closestFormationEntity];

        if (mathx.lengthSqr(closestFormation.Position - t.Position) > RangedUnitData.ArcherAttackRangeSqr)
        {
            archer.attackCycle = -1;
            archers[index]     = archer;

            return;
        }

        bool readyToAttack = false;

        if (archer.attackCycle < 0)
        {
            archer.attackCycle = 0;
        }

        archer.attackCycle = archerAttackCycle;

        long  archerAttackVarianceSeed = index;
        float attackTimeVariance       = Randomizer.Float(-0.15f, 0.15f, ref archerAttackVarianceSeed);
        float varianceHitTime          = archerHitTime + attackTimeVariance;

        // Check Attack cycles
        if (archerAttackCycle >= varianceHitTime && prevArcherAttackCycle < varianceHitTime)
        {
            readyToAttack = true;
        }

        if (readyToAttack)
        {
            long seed = index * randomizer;

            float3 formationSideVector = closestFormation.Forward.zyx;
            formationSideVector.x = -formationSideVector.x;

            float3 targetPosition = closestFormation.Position + closestFormation.formationSide * formationSideVector * closestFormation.Width;
            targetPosition += new float3(Randomizer.Float(-20, 20, ref seed), 0, Randomizer.Float(-20, 20, ref seed));

            float3 relativeVector        = targetPosition - t.Position;
            float  distance              = math.length(relativeVector.xz);
            float3 arrowStartingPosition = t.Position + new float3(0f, 3f, 0f);

            //if (math.all(math.abs(t.Position) < new float3(2, 2, 2)))
            //{
            //	Debug.Log(index + " " + t.FormationIndex + " " + t.IndexInFormation + " " + t.Position);
            //}

            float angle   = Mathf.PI * math.lerp(0.36f, 0.2f, math.saturate(distance / RangedUnitData.ArcherAttackRange));
            float variant = Mathf.PI * 0.05f;
            angle = Randomizer.Float(angle - variant, angle + variant, ref seed);

            float velocity = GetArrowVelocity(distance, angle, arrowStartingPosition.y - closestFormation.Position.y);

            float3 shootingVector = math.normalize(new float3(relativeVector.x, 0, relativeVector.z));

            // rotate the vector
            float3     rotAxis  = math.cross(shootingVector, new float3(0, 1, 0));
            Quaternion rotation = AngleAxis(angle, rotAxis);

            shootingVector = rotation * shootingVector;

            var arrow = new ArrowData()
            {
                IsFriendly = (minionConstData[index].IsFriendly ? 1 : 0)
            };
            // FIREEE!!!
            arrow.position = arrowStartingPosition;
            arrow.velocity = shootingVector * velocity;
            arrow.active   = true;

            createdArrowsQueue.Enqueue(arrow);
        }
        archers[index] = archer;
    }
示例#18
0
    protected override JobHandle OnUpdate(JobHandle inputDeps)
    {
        if (rigidbodies.Length == 0)
        {
            return(inputDeps);
        }

        if (Input.GetKeyDown(KeyCode.Alpha1))
        {
            RaycastHit lastHit;
            Ray        ray = Camera.main.ScreenPointToRay(Input.mousePosition);
            if (Physics.Raycast(ray, out lastHit, Mathf.Infinity, FormationSystem.GroundLayermask))
            {
                GameObject go        = ObjectPooler._this.Get(PoolType.FireLance);
                FireLance  fireLance = go.GetComponent <FireLance>();
                go.SetActive(true);
                fireLance.PlayEffect(go.transform.position, lastHit.point);
            }
        }
        else if (Input.GetKeyDown(KeyCode.Alpha2))
        {
            RaycastHit lastHit;
            Ray        ray = Camera.main.ScreenPointToRay(Input.mousePosition);
            if (Physics.Raycast(ray, out lastHit, Mathf.Infinity, FormationSystem.GroundLayermask))
            {
                for (int i = 0; i < 1024; ++i)
                {
                    float3 srcPos         = new float3(-30, 22, 295);
                    float3 targetPosition = lastHit.point;
                    targetPosition += new float3(Random.Range(-20, 20), 0, Random.Range(-20, 20));

                    float3 relativeVector        = targetPosition - srcPos;
                    float  distance              = math.length(relativeVector.xz);
                    float3 arrowStartingPosition = srcPos + new float3(0f, 3f, 0f);

                    //if (math.all(math.abs(t.Position) < new float3(2, 2, 2)))
                    //{
                    //	Debug.Log(index + " " + t.FormationIndex + " " + t.IndexInFormation + " " + t.Position);
                    //}

                    float spellVelocityScale = 0.1f;
                    float angle   = Mathf.PI * spellVelocityScale * math.lerp(0.36f, 0.2f, math.saturate(distance / RangedUnitData.ArcherAttackRange));
                    float variant = Mathf.PI * spellVelocityScale * 0.05f;
                    angle = Random.Range(angle - variant, angle + variant);

                    float velocity = ArcherJob.GetArrowVelocity(distance, angle, arrowStartingPosition.y - targetPosition.y);

                    float3 shootingVector = math.normalize(new float3(relativeVector.x, 0, relativeVector.z));

                    // rotate the vector
                    float3     rotAxis  = math.cross(shootingVector, new float3(0, 1, 0));
                    Quaternion rotation = ArcherJob.AngleAxis(angle, rotAxis);

                    shootingVector = rotation * shootingVector;
                    var arrow = new ArrowData()
                    {
                        IsFriendly = 1
                    };
                    // FIREEE!!!
                    arrow.position = arrowStartingPosition;
                    arrow.velocity = shootingVector * velocity;
                    arrow.active   = true;

                    unitLifecycleManager.createdArrows.Enqueue(arrow);
                }
            }
        }


        inputDeps.Complete();

        CombinedExplosionHandle.Complete();
        spellData.Clear();
        foreach (var explosion in SpellExplosionsQueue)
        {
            spellData.Add(new SpellData()
            {
                randomHorizontal        = explosion.settings.randomHorizontal,
                blastDirectionFactor    = explosion.settings.blastDirectionFactor,
                blastDirectionModifier  = explosion.settings.blastDirectionModifier,
                useInvertedDistance     = explosion.settings.useInvertedDistance,
                explosionDistance       = explosion.settings.explosionDistance,
                verticalComponentFactor = explosion.settings.verticalComponentFactor,
                explosionPosition       = explosion.position
            });
        }
        SpellExplosionsQueue.Clear();

        if (spellData.Length > 0)
        {
            var explosionJob = new ApplyExplosionJob()
            {
                entities          = rigidbodies.entities,
                entitiesForFlying = unitLifecycleManager.entitiesForFlying,
                transforms        = rigidbodies.transforms,
                frameCount        = Time.frameCount,
                rigidbodies       = rigidbodies.rigidbodies,
                spells            = spellData
            };

            CombinedExplosionHandle = explosionJob.Schedule(rigidbodies.Length, SimulationState.HumongousBatchSize, inputDeps);
        }
        else
        {
            CombinedExplosionHandle = default(JobHandle);
        }

        return(CombinedExplosionHandle);
    }
示例#19
0
    public void SpawnArrow(ArrowData arrowData)
    {
        var entity = entityManager.CreateEntity(typeof(ArrowData));

        entityManager.SetComponentData(entity, arrowData);
    }
示例#20
0
 public void NewArrow()
 {
     CurrentArrow = new ArrowData();
 }
        private void OnRenderObjectEvent()
        {
            if (Camera.current != Camera.main || MapView.MapIsEnabled)
            {
                return;
            }

            if (CameraManager.Instance.currentCameraMode == CameraManager.CameraMode.IVA &&
                vessel == FlightGlobals.ActiveVessel)
            {
                return;
            }

            if (vessel != FlightGlobals.ActiveVessel)
            {
                if (Vector3.Distance(FlightGlobals.ActiveVessel.transform.position, vessel.transform.position) >
                    PhysicsGlobals.Instance.VesselRangesDefault.subOrbital.unload)
                {
                    MarkersEnabled = false;
                    return;
                }
            }

            Profiler.BeginSample("FlightMarkersRenderDraw");

            DrawTools.DrawSphere(vessel.CoM, XKCDColors.Yellow, 1.0f * SphereScale);

            DrawTools.DrawSphere(vessel.rootPart.transform.position, XKCDColors.Green, 0.25f);

            _centerOfThrust = FindCenterOfThrust(vessel.rootPart);
            if (_centerOfThrust.Direction != Vector3.zero)
            {
                DrawTools.DrawSphere(_centerOfThrust.Position, XKCDColors.Magenta, 0.95f * SphereScale);
                DrawTools.DrawArrow(_centerOfThrust.Position, _centerOfThrust.Direction.normalized * ArrowLength, XKCDColors.Magenta);
            }

            if (vessel.staticPressurekPa > 0f)
            {
                _centerOfLift = FindCenterOfLift(vessel.rootPart, vessel.srf_velocity, vessel.altitude,
                                                 vessel.staticPressurekPa, vessel.atmDensity);
                _bodyLift = FindBodyLift(vessel.rootPart);
                _drag     = FindDrag(vessel.rootPart);

                var activeLift = LiftFlag.None;
                if (_centerOfLift.Total > CenterOfLiftCutoff)
                {
                    activeLift |= LiftFlag.SurfaceLift;
                }
                if (_bodyLift.Total > BodyLiftCutoff)
                {
                    activeLift |= LiftFlag.BodyLift;
                }

                var drawCombined = _combineLift && (activeLift & CombineFlags) == CombineFlags;

                if (drawCombined)
                {
                    _positionAvg.Reset();
                    _directionAvg.Reset();

                    if ((activeLift & LiftFlag.SurfaceLift) == LiftFlag.SurfaceLift)
                    {
                        _positionAvg.Add(_centerOfLift.Position);
                        _directionAvg.Add(_centerOfLift.Direction.normalized);
                    }

                    if ((activeLift & LiftFlag.BodyLift) == LiftFlag.BodyLift)
                    {
                        _positionAvg.Add(_bodyLift.Position);
                        _directionAvg.Add(_bodyLift.Direction.normalized);
                    }

                    DrawTools.DrawSphere(_positionAvg.Get(), XKCDColors.Purple, 0.9f * SphereScale);
                    DrawTools.DrawArrow(_positionAvg.Get(), _directionAvg.Get().normalized *ArrowLength, XKCDColors.Purple);
                }
                else
                {
                    if ((activeLift & LiftFlag.SurfaceLift) == LiftFlag.SurfaceLift)
                    {
                        DrawTools.DrawSphere(_centerOfLift.Position, XKCDColors.Blue, 0.9f * SphereScale);
                        DrawTools.DrawArrow(_centerOfLift.Position, _centerOfLift.Direction.normalized * ArrowLength, XKCDColors.Blue);
                    }

                    if ((activeLift & LiftFlag.BodyLift) == LiftFlag.BodyLift)
                    {
                        DrawTools.DrawSphere(_bodyLift.Position, XKCDColors.Cyan, 0.85f * SphereScale);
                        DrawTools.DrawArrow(_bodyLift.Position, _bodyLift.Direction.normalized * ArrowLength, XKCDColors.Cyan);
                    }
                }

                if (_drag.Total > DragCutoff)
                {
                    DrawTools.DrawSphere(_drag.Position, XKCDColors.Red, 0.8f * SphereScale);
                    DrawTools.DrawArrow(_drag.Position, _drag.Direction.normalized * ArrowLength, XKCDColors.Red);
                }
            }

            Profiler.EndSample();
        }
示例#22
0
    // GENERATE puzzle and set up arrows
    void Start()
    {
        CustomizeStorage CustomizeStorage = GameObject.Find("_SceneManager").GetComponent <CustomizeStorage>();

        ChangeScene = GameObject.Find("_SceneManager").GetComponent <ChangeScene>();
        string thisSceneName = SceneManager.GetActiveScene().name;

        if (!thisSceneName.Equals("Tutorial"))
        {
            ChangeScene.tutorialIndex = 0;
        }

        bSize = ChangeScene.bSize;  // get bSize
        for (int i = 0; i < 8; i++)
        {
            degrees[i] = i * 45;
        }                                                       // set up degree values

        // if tutorial ?
        int tutorialIndex = ChangeScene.tutorialIndex;

        if (tutorialIndex != 0)
        {
            bSize      = 3;
            solution2d = new int[bSize, bSize];
            string tutorMessage = "";
            if (tutorialIndex == 1)
            {
                degree2d = new int[3, 3] {
                    { -1, 180, 180 }, { -1, -1, 90 }, { 0, 0, 90 }
                };
                tutorMessage = "Your goal is to activate all arrows, tapping on one will activate it.";
            }
            else if (tutorialIndex == 2)
            {
                degree2d = new int[3, 3] {
                    { 0, 270, 180 }, { -1, 270, -1 }, { 0, -1, 90 }
                };
                tutorMessage = "It's like jumping from arrow to arrow. You'd be on the last arrow you activated, and you can only jump to the ones which are in your direction, no matter how far.";
            }
            else if (tutorialIndex == 3)
            {
                degree2d = new int[3, 3] {
                    { 315, -1, 270 }, { -1, 45, 270 }, { 45, -1, 135 }
                };
                tutorMessage = "They can go in diagonal directions as well! If you activate the invalid arrow then everything will reset.";
            }
            else if (tutorialIndex == 4)
            {
                degree2d = new int[3, 3] {
                    { 315, -1, 270 }, { -1, 45, -1 }, { 0, 180, 135 }
                };
                tutorMessage = "It never hurts to just sit back and think. Hint: Start with the arrow at the center bottom!";
            }
            else if (tutorialIndex == 5)
            {
                degree2d = new int[3, 3] {
                    { -1, -1, -1 }, { -1, -1, -1 }, { -1, -1, -1 }
                };
                tutorMessage = "You have completed the tutorial! Here are some tips:\n\n" +
                               "The last activated arrow would blink.\n\n" +
                               "The puzzles are all random, but you can develop your own strategy to solve any puzzle.\n\n" +
                               "The higher the difficulty, the higher the reward. Want to level up fast? Avoid using hints!\n\n" +
                               "You can directly unlock items in shop with hint points!\n\n" +
                               "For every 5 levels up your bonus multiplier would increase, it can also be found by opening packs.";
            }
            GameObject.Find("solutiontext").GetComponent <TextMeshProUGUI>().text = tutorMessage;
        }
        else
        {
            setUpPlay();

            /*
             * // print solution (keep this) //////////////////////////////
             * string solu = "";
             * for (int i = 0; i < bSize; i++)
             * {
             *  string line = "";
             *  for (int j = 0; j < bSize; j++)
             *  {
             *      int l = solution2d[i, j];
             *      line += l + ((l < 10) ? "   " : "  ");
             *  }
             *  solu += line + "\n";
             * }
             *
             * GameObject.Find("solutiontext").GetComponent<TextMeshProUGUI>().text = solu;*/
        }

        Color c;

        // get the selected arrow skin and color
        if (thisSceneName.Equals("Tutorial"))
        {
            image = CustomizeStorage.arrowImage[0];
            c     = CustomizeStorage.arrowColors[0];
        }
        else
        {
            image = CustomizeStorage.arrowImage[CustomizeStorage.selectedArrow];
            c     = CustomizeStorage.arrowColors[CustomizeStorage.selectedArrow];
        }

        // cell size
        cellSize = 22f / bSize;        // default
        float s = 68 / (bSize - 0.2f); // for positioning

        // set up arrows
        for (int y = bSize - 1; y > -1; y--)
        {
            for (int x = 0; x < bSize; x++)
            {
                float deg = degree2d[y, x] + 0.0f;

                // y is SAV*speed +25   (speed is at ABMovement, update yPos)
                startAnimateValue = 20;
                // instantiate => position and rotation
                clone = Instantiate(arrowButton,
                                    new Vector3(s * (x - (bSize - 1) * 0.5f), -s * (y - (bSize - 1) * 0.5f) + startAnimateValue * 2 + 25, 0),
                                    Quaternion.Euler(0, 0, deg));

                // set parent
                clone.transform.SetParent(ArrowsBoard);

                // re-scale
                clone.transform.localScale = new Vector3(cellSize, cellSize, 0);

                // set image
                spriteHolder = clone.GetComponent <SpriteRenderer>();
                if (CustomizeStorage.selectedArrow == 48 && !thisSceneName.Equals("Tutorial"))  // (if random ? set new img and color)
                {
                    int randomSelect = Random.Range(0, 48);
                    image = CustomizeStorage.arrowImage[randomSelect];
                    c     = CustomizeStorage.arrowColors[randomSelect];
                }
                spriteHolder.sprite = image;
                spriteHolder.color  = c;

                // set data
                dataHolder = clone.GetComponent <ArrowData>();
                dataHolder.changePos(x, y);

                // TUTORIAL TWIST!
                if (tutorialIndex != 0 && deg == -1)
                {
                    Destroy(clone);
                }
            }
        }
    }
示例#23
0
 public void OnAddToHistory(ArrowData arrow)
 {
     AddToHistory?.Invoke(arrow);
 }
示例#24
0
    public void newPlayMove(ArrowData obj, UpdateTint tintObj)
    {
        bool correct = false; // qualified to be activated

        // not the first arrow to be pressed? => futher check
        if (playVisited > 0)
        {
            // not within the direction of last object => return
            bool q            = Mathf.Abs(lastPressed.cx - obj.cx) == Mathf.Abs(lastPressed.cy - obj.cy);
            int  lastArrowDeg = degree2d[lastPressed.cy, lastPressed.cx];
            // up
            if (lastArrowDeg == 90)
            {
                correct = obj.cx == lastPressed.cx && obj.cy < lastPressed.cy;
            }
            // down
            else if (lastArrowDeg == 270)
            {
                correct = obj.cx == lastPressed.cx && obj.cy > lastPressed.cy;
            }
            // left
            else if (lastArrowDeg == 180)
            {
                correct = obj.cy == lastPressed.cy && obj.cx < lastPressed.cx;
            }
            // right
            else if (lastArrowDeg == 0)
            {
                correct = obj.cy == lastPressed.cy && obj.cx > lastPressed.cx;
            }
            // up right
            else if (lastArrowDeg == 45)
            {
                correct = q && obj.cy <lastPressed.cy && obj.cx> lastPressed.cx;
            }
            // down right
            else if (lastArrowDeg == 315)
            {
                correct = q && obj.cy > lastPressed.cy && obj.cx > lastPressed.cx;
            }
            // down left
            else if (lastArrowDeg == 225)
            {
                correct = q && obj.cy > lastPressed.cy && obj.cx < lastPressed.cx;
            }
            // up left
            else if (lastArrowDeg == 135)
            {
                correct = q && obj.cy < lastPressed.cy && obj.cx < lastPressed.cx;
            }
        }
        else
        {
            correct = true;
        }
        if (!correct)
        {
            if (PlayerPrefs.GetString("sound").Equals("on"))
            {
                incorrectSound.Play();
            }
            resetAll();
        }
        else  // CORRECT!
        {
            if (PlayerPrefs.GetString("sound").Equals("on"))
            {
                correctSound.Play();
            }
            obj.activated = true;
            playVisited++;
            lastPressed        = obj;
            lastPressedTintObj = tintObj;
            blinkTimer         = 150; //// set timer for blinking

            // check win (IF TUTORIAL ELSE NORMAL PLAY)
            if (ChangeScene.tutorialIndex != 0 && playVisited == 6)
            {
                won = true;
            }
            else if (playVisited == bSize * bSize)
            {
                won = true;
                ChangeScene.adsPopCount -= 1;

                // add to solves
                if (bSize == 3)
                {
                    PlayerPrefs.SetInt("easy", PlayerPrefs.GetInt("easy") + 1);
                }
                else if (bSize == 4)
                {
                    PlayerPrefs.SetInt("normal", PlayerPrefs.GetInt("normal") + 1);
                }
                else if (bSize == 5)
                {
                    PlayerPrefs.SetInt("hard", PlayerPrefs.GetInt("hard") + 1);
                }
            }
        }
    }
示例#25
0
        public int LoadFromData(string[] data, int pointer)
        {
            string s = "";

            Style       = data[pointer++].Replace("dance-", "").TrimEnd(':');
            Style       = Style[0].ToString().ToUpper() + Style.Substring(1);
            Description = data[pointer++].TrimEnd(':');
            Difficulty  = data[pointer++].TrimEnd(':');
            Difficulty  = Difficulty[0].ToString().ToUpper() + Difficulty.Substring(1);
            Rating      = Convert.ToInt32(data[pointer++].TrimEnd(':'));

            pointer++;

            List <string> measure = new List <string>();
            List <string> allData = new List <string>();

            while (s != ";")
            {
                measure.Clear();
                s = data[pointer++];
                while (s != "," && s != ";")
                {
                    measure.Add(s);
                    allData.Add(s);
                    s = data[pointer++];
                }

                switch (measure.Count)
                {
                case 4:
                    for (int i = 0; i < 4; i++)
                    {
                        ArrowData.Add(measure[i].ToArrow());
                        for (int j = 0; j < 3; j++)
                        {
                            ArrowData.Add(Arrow.None);
                        }
                    }
                    break;

                case 8:
                    for (int i = 0; i < 8; i++)
                    {
                        ArrowData.Add(measure[i].ToArrow());
                        ArrowData.Add(Arrow.None);
                    }
                    break;

                case 12:
                    for (int i = 0; i < 4; i++)
                    {
                        ArrowData.Add(Arrow.All);
                        ArrowData.Add(measure[i * 3].ToArrow());
                        ArrowData.Add(measure[i * 3 + 1].ToArrow());
                        ArrowData.Add(measure[i * 3 + 2].ToArrow());
                    }
                    break;

                case 16:
                    for (int i = 0; i < 16; i++)
                    {
                        ArrowData.Add(measure[i].ToArrow());
                    }
                    break;
                }
            }

            Arrow freezesOn = Arrow.None;

            foreach (var a in allData)
            {
                FreezeData.Add(a.ToFreeze(freezesOn, out freezesOn));
            }

            return(pointer);
        }