Beispiel #1
0
 private void ClearFocusPointLocation()
 {
     FocusPoint.ClearValue(Canvas.TopProperty);
     FocusPoint.ClearValue(Canvas.BottomProperty);
     FocusPoint.ClearValue(Canvas.LeftProperty);
     FocusPoint.ClearValue(Canvas.RightProperty);
 }
    public void SetViewPoint(FocusPoint pFocusPoint, bool pOverrideTransform = false)
    {
        //Debug.Log("Calling camera to set to " + pFocusObject.ToString());
        if (!_initialized)
        {
            Debug.Log("CameraHandler: Can not run update, static class was not initialized!");
            return;
        }
        SetLerpTime(pFocusPoint);
        if (pFocusPoint == FocusPoint.TopLevel)
        {
            _parentPoints[FocusPoint.TopLevel].position = _parentPoints[_focusPoint].position;
            _parentPoints[FocusPoint.TopLevel].rotation = _parentPoints[_focusPoint].rotation;
        }


        SetFocusPoint(pFocusPoint);
        // Set _focusPoint as parent
        SetCameraParent(_parentPoints[_focusPoint]);
        // Set _fromPoint
        SetFromPoint(_camera.transform);
        _focusPointReached = false;
        if (pOverrideTransform)
        {
            _camera.transform.position = _parentPoints[_focusPoint].position;
            _camera.transform.rotation = _parentPoints[_focusPoint].rotation;
            SetFromPoint(_camera.transform);
            _focusPointReached = true;
        }
        _currentLerpTime = 0;
    }
 public FocalPoints(FocusPoint hazy, FocusPoint alert, FocusPoint inTune, FocusPoint sharp)
 {
     fp = new Dictionary <FocusThreshold, FocusPoint>();
     fp.Add(FocusThreshold.HAZY, hazy);
     fp.Add(FocusThreshold.ALERT, alert);
     fp.Add(FocusThreshold.IN_TUNE, inTune);
     fp.Add(FocusThreshold.SHARP, sharp);
 }
Beispiel #4
0
    public void SetFocusPointOffset(Vector3 offset)
    {
        //Set focus point of the camera
        FocusPoint fPoint = GetComponent <FocusPoint>();

        if (fPoint != null)
        {
            fPoint.offset = offset;
        }
    }
        public void testCreatureDeserialization()
        {
            LibraryLoader.loadMoveLibrary();

            string     creatureJSONString = "{\"creatureId\":1,\n\"creatureName\":\"\",\n\"baseStats\":[10,10,10,10],\n\"abilityId\":1,\n\"moves\":[\"Strike\",\"Slam\"],\n\"focalPoints\":[\n{\n\"description\":\"Small boost to strength\",\n\"statMods\":{\n\"STR\":[5,1]\n}\n},\n{\n\"description\":\"Small boost to armor\",\n\"statMods\":{\n\"ARM\":[5, 1]\n}\n},\n{\n\"description\":\"Additional armor scaling\",\n\"statMods\":{\n\"ARM\":[0, 1.1]\n}\n},\n{\n\"description\":\"Small boost to speed\",\n\"statMods\":{\n\"SPD\":[5, 1]\n}\n}\n],\n\"baseForm\":{\n\"creatureTypes\":[\"Vital\"],\n\"abilityId\":1,\n\"revealAction\":null\n},\n\"availableForms\":[\n{\n\"creatureTypes\":[\"Flame\"],\n\"statMods\":{\n\"STR\":[5, 1],\n\"ARM\":[0, 1],\n\"SPD\":[0, 1]\n},\n\"moveId\":null,\n\"abilityId\":1,\n\"revealAction\":null\n}\n]\n}";
            JSONObject creatureJSON       = JSONObject.Create(creatureJSONString);

            Creature actual = Creature.fromJSONObject(creatureJSON);

            HashSet <Move> expectedMoves = new HashSet <Move>();

            expectedMoves.Add(MoveLibrary.get("Strike"));
            expectedMoves.Add(MoveLibrary.get("Slam"));
            StatModifier           sm1 = new StatModifier(5, 1);
            StatModifier           sm2 = new StatModifier(0, 1.1);
            StatModifier           sm3 = new StatModifier(0, 1);
            FocusPoint             fp1 = new FocusPoint(null, null, makeListOfStatMod(StatName.STR, sm1), "Small boost to strength");
            FocusPoint             fp2 = new FocusPoint(null, null, makeListOfStatMod(StatName.ARM, sm1), "Small boost to armor");
            FocusPoint             fp3 = new FocusPoint(null, null, makeListOfStatMod(StatName.ARM, sm2), "Additional armor scaling");
            FocusPoint             fp4 = new FocusPoint(null, null, makeListOfStatMod(StatName.SPD, sm1), "Small boost to speed");
            FocalPoints            expectedFocalPoints = new FocalPoints(fp1, fp2, fp3, fp4);
            CreatureStats          expectedBaseStats   = new CreatureStats(10, 10, 10, 10);
            Ability                expectedAbility     = null;
            HashSet <CreatureType> expectedTypesBase   = new HashSet <CreatureType>();

            expectedTypesBase.Add(CreatureType.VITAL);
            CreatureForm expectedBaseForm = new CreatureForm(expectedTypesBase, null, null);

            HashSet <CreatureType> expectedTypesForm = new HashSet <CreatureType>();

            expectedTypesForm.Add(CreatureType.FLAME);

            List <Pair <StatName, StatModifier> > expectedFormMods = new List <Pair <StatName, StatModifier> >();

            expectedFormMods.Add(new Pair <StatName, StatModifier>(StatName.STR, sm1));
            expectedFormMods.Add(new Pair <StatName, StatModifier>(StatName.ARM, sm3));
            expectedFormMods.Add(new Pair <StatName, StatModifier>(StatName.SPD, sm3));
            CreatureForm expectedAltForm = new CreatureForm(expectedTypesForm, expectedFormMods, null, null, null);

            //"availableForms\":[\n{\n\"creatureTypes\":[\"Flame\"],\n\"statMods\":{\n\"STR\":[5, 1],\n\"ARM\":[0, 1],\n\"SPD\":[0, 1]\n},\n\"moveId\":null,\n\"abilityId\":1,\n\"revealAction\":null\n}\n]

            List <CreatureForm> expectedAvailableForms = new List <CreatureForm>();

            expectedAvailableForms.Add(expectedAltForm);

            foreach (Pair <StatName, StatModifier> pair in expectedAltForm.statMods)
            {
                Debug.Log("Alt form mod: " + pair.ToString());
            }

            Creature expected = new Creature(1, "", expectedMoves, expectedFocalPoints, expectedAbility, expectedBaseStats, expectedBaseForm, expectedAvailableForms);

            Assert.That(expected.Equals(actual));
        }
        public void testFocusPointDeserialization()
        {
            string     focusPointString = "{\n\"description\":\"Small boost to speed\",\n\"statMods\":{\n\"SPD\":[5, 1]\n}\n}";
            FocusPoint actual           = FocusPoint.fromJSONObject(JSONObject.Create(focusPointString));

            List <Pair <StatName, StatModifier> > statMods = new List <Pair <StatName, StatModifier> >();

            statMods.Add(new Pair <StatName, StatModifier>(StatName.SPD, new StatModifier(5, 1)));

            FocusPoint expected = new FocusPoint(null, null, statMods, "Small boost to speed");

            Assert.That(actual.Equals(expected));
        }
Beispiel #7
0
        public void testMoveManagerGetListOfHighestPrio()
        {
            Watchers testWatchers = new Watchers();

            CreatureStats  cs1 = new CreatureStats(1, 1, 1, 10);
            CreatureForm   bf1 = new CreatureForm(new HashSet <CreatureType>(new CreatureType[] { CreatureType.VITAL }), null, null);
            FocusPoint     f1  = new FocusPoint(null, null, null, null);
            FocalPoints    fp1 = new FocalPoints(f1, f1, f1, f1);
            Creature       c1  = new Creature(0, "", null, fp1, null, cs1, bf1, null);
            BattleCreature bc1 = new BattleCreature(c1, Owner.ALLY, testWatchers);

            CreatureStats  cs2 = new CreatureStats(1, 1, 1, 20);
            CreatureForm   bf2 = new CreatureForm(new HashSet <CreatureType>(new CreatureType[] { CreatureType.VITAL }), null, null);
            FocusPoint     f2  = new FocusPoint(null, null, null, null);
            FocalPoints    fp2 = new FocalPoints(f2, f2, f2, f2);
            Creature       c2  = new Creature(0, "", null, fp2, null, cs2, bf2, null);
            BattleCreature bc2 = new BattleCreature(c2, Owner.ALLY, testWatchers);

            Move move1 = new Move(0, "TestMove1", "", Move.MoveClass.ATTACK, TargetClass.ENEMY_SINGLE, null, CreatureType.VITAL, 0, 0, 0);
            Move move2 = new Move(1, "TestMove2", "", Move.MoveClass.ATTACK, TargetClass.ENEMY_SINGLE, null, CreatureType.VITAL, 1, 0, 0);
            Move move3 = new Move(2, "TestMove3", "", Move.MoveClass.ATTACK, TargetClass.ENEMY_SINGLE, null, CreatureType.VITAL, -3, 0, 0);

            MoveContext context1 = new MoveContext(move1, bc1, null, null, null);
            MoveContext context2 = new MoveContext(move2, bc2, null, null, null);
            MoveContext context3 = new MoveContext(move3, bc1, null, null, null);
            MoveContext context4 = new MoveContext(move1, bc2, null, null, null);

            //bc2 moves faster than bc1
            //Order of prio: move3, move1, move2
            //Resulting move order should then be: context3, context4, context1, context2
            HashSet <MoveContext> contexts    = new HashSet <MoveContext>(new MoveContext[] { context1, context2, context3, context4 });
            MoveManager           moveManager = new MoveManager(null, null, contexts);

            MoveContext actual1 = moveManager.getNextMove();
            MoveContext actual2 = moveManager.getNextMove();

            Assert.That(moveManager.getMovesRemaining() == 2);
            Assert.That(moveManager.isTurnOver() == false);

            MoveContext actual3 = moveManager.getNextMove();
            MoveContext actual4 = moveManager.getNextMove();

            Assert.That(moveManager.getMovesRemaining() == 0);
            Assert.That(moveManager.isTurnOver());

            Assert.That(actual1.Equals(context3));
            Assert.That(actual2.Equals(context4));
            Assert.That(actual3.Equals(context1));
            Assert.That(actual4.Equals(context2));
        }
Beispiel #8
0
    void ClickObject()
    {
        var        ray = Camera.main.ScreenPointToRay(Input.mousePosition);
        RaycastHit hitInfo;

        if (Physics.Raycast(ray, out hitInfo, 1000))
        {
            var rig = hitInfo.collider;

            if (rig.CompareTag("Interactable"))
            {
                Debug.Log(rig.name + " clicked.");
                fS             = rig.GetComponent <FocusPoint>();
                changePosition = true;
            }
        }
    }
    public static FocalPoints fromJSONObject(JSONObject json)
    {
        if (json.type != JSONObject.Type.ARRAY)
        {
            throw new System.Exception("FocalPoints deserialization failed: json is not array");
        }
        if (json.list.Count != 4)
        {
            throw new System.Exception("FocalPoints deserialization failed: item count is not 4");
        }

        List <FocusPoint> points = new List <FocusPoint>();

        foreach (JSONObject j in json.list)
        {
            points.Add(FocusPoint.fromJSONObject(j));
        }

        return(new FocalPoints(points[0], points[1], points[2], points[3]));
    }
Beispiel #10
0
    public override bool Equals(Object obj)
    {
        if (!(obj is FocusPoint))
        {
            return(false);
        }
        FocusPoint other = (FocusPoint)obj;

        bool isEqual = true;

        if (!(statModifiers == null && other.statModifiers == null))
        {
            isEqual &= statModifiers.Count == other.statModifiers.Count;
            isEqual &= (new CreatureStats()).getStatsWithMods(statModifiers).Equals((new CreatureStats()).getStatsWithMods(other.statModifiers));
        }

        isEqual &= (battleAction == null && other.battleAction == null) || battleAction.Equals(other.battleAction);
        isEqual &= (focusTrigger == null && other.focusTrigger == null) || focusTrigger.Equals(other.focusTrigger);

        return(isEqual);
    }
 private void SetLerpTime(FocusPoint pFocusPoint)
 {
     // From Start to Ocean
     if (_focusPoint == FocusPoint.Start && pFocusPoint == FocusPoint.End)
     {
         _totalLerpTime = _menuToOceanDuration;
     }
     // From Ocean to Hook
     if (_focusPoint == FocusPoint.Ocean && pFocusPoint == FocusPoint.Hook)
     {
         _totalLerpTime = _oceanToHookDuration;
     }
     // From Hook to Ocean
     if (_focusPoint == FocusPoint.Hook && pFocusPoint == FocusPoint.Ocean)
     {
         _totalLerpTime = _hookToOceanDuration;
     }
     // From Ocean to End
     if (_focusPoint == FocusPoint.Ocean && pFocusPoint == FocusPoint.End)
     {
         _totalLerpTime = _menuToOceanDuration;
     }
 }
Beispiel #12
0
        private void SaveC54XXPoint(string filepath, string faceType)
        {
            FocusPoint[] whitePoint = new FocusPoint[WhiteFpSet.Count];
            FocusPoint[] blackPoint = new FocusPoint[BlackFpSet.Count];
            WhiteFpSet.CopyTo(whitePoint,0);
            BlackFpSet.CopyTo(blackPoint,0);

            StreamWriter sw = new StreamWriter(new FileStream(filepath, FileMode.OpenOrCreate), Encoding.ASCII);
            //保存白点
            sw.WriteLine(string.Format("// * * * * * * * * * * * * * {0} * * * * * * * * * * * * * //", faceType));
            sw.WriteLine(string.Format("#define  WHITE_POINT_SIZE{0}	{1}", faceType, WhiteFpSet.Count));
            sw.WriteLine(string.Format("const WORD WhitePoint{0}[WHITE_POINT_SIZE{0}] = ", faceType, faceType));
            sw.WriteLine("{");
            for (int i = 0; i < whitePoint.Length;i++ )
            {
                int x = whitePoint[i].x;
                int y = whitePoint[i].y;
                sw.WriteLine(GenOneLine(x, y));
                //sw.WriteLine(string.Format("\t\t0x{0:X},\t\t//{1},{2}", xy, x, y));
            }
            sw.WriteLine("};");
            sw.WriteLine("");

            sw.WriteLine(string.Format("const WORD WhiteThreshold{0}[(WHITE_POINT_SIZE{0}+1)/2] = ", faceType, faceType));
            sw.WriteLine("{");
            for (int i=0; i<(whitePoint.Length+1)/2; i++)
            {
                int thr1 = (whitePoint[i*2].g)&0xff;
                int thr2 = i * 2 + 1 < whitePoint.Length ? whitePoint[i * 2 + 1].g : 0;
                sw.WriteLine(GenOneLine(thr1, thr2));
                //sw.WriteLine(string.Format("\t\t0x{0:X},\t\t//{1},{2}", thr, thr1, thr2));
            }
            sw.WriteLine("};");
            sw.WriteLine("");

            //保存黑点
            sw.WriteLine(string.Format("#define  BLACK_POINT_SIZE{0}	{1}", faceType, BlackFpSet.Count));
            sw.WriteLine(string.Format("const WORD BlackPoint{0}[BLACK_POINT_SIZE{0}] = ", faceType, faceType));
            sw.WriteLine("{");
            for (int i = 0; i < blackPoint.Length; i++ )
            {
                int x = (blackPoint[i].x)&0xff;
                int y = (blackPoint[i].y)&0xff;
                sw.WriteLine(GenOneLine(x, y));
                //sw.WriteLine(string.Format("\t\t0x{0:X},\t\t//{1},{2}", xy, x, y));
            }
            sw.WriteLine("};");
            sw.WriteLine("");

            sw.WriteLine(string.Format("const WORD BlackThreshold{0}[(BLACK_POINT_SIZE{0}+1)/2] = ", faceType, faceType));
            sw.WriteLine("{");
            for (int i = 0; i < (blackPoint.Length + 1) / 2; i++)
            {
                int thr1 = (blackPoint[i * 2].g)&0xff;
                int thr2 = i * 2 + 1 < blackPoint.Length ? blackPoint[i * 2 + 1].g : 0;
                sw.WriteLine(GenOneLine(thr1, thr2));
                //sw.WriteLine(string.Format("\t\t0x{0:X},\t\t//{1},{2}", thr, thr1, thr2));
            }
            sw.WriteLine("};");
            sw.WriteLine(string.Format("// * * * * * * * * * * * * * {0} * * * * * * * * * * * * * //", faceType));

            sw.Flush();
            sw.Close();
        }
Beispiel #13
0
        /// <summary>
        /// 从DM642格式的文件中载入点集
        /// </summary>
        /// <param name="filepath">文件路径</param>
        /// <returns>是否载入成功,载入失败的原因为点文件不存在</returns>
        private bool LoadDm642Point(string filepath)
        {
            try
            {
                WhiteFpSet.Clear();
                BlackFpSet.Clear();
                if (!File.Exists(filepath)) return false;
                StreamReader sr = new StreamReader(filepath);
                char[] separator = { '\t', ' ', ',' };

                string getString;
                while ((getString = sr.ReadLine()) != null)
                {
                    string[] fpstr = getString.Split(separator, StringSplitOptions.RemoveEmptyEntries);
                    if (fpstr.Length == 3 && fpstr[0].Length <= 3 && fpstr[1].Length <= 3 && fpstr[2].Length <= 3)
                    {
                        FocusPoint fp = new FocusPoint(short.Parse(fpstr[0]), short.Parse(fpstr[1]), short.Parse(fpstr[2]));
                        if (fp.g < 256)
                        {
                            WhiteFpSet.AddLast(fp);
                        }
                        else
                        {
                            BlackFpSet.AddLast(new FocusPoint(fp.x, fp.y, (short)(fp.g - 256)));
                        }
                    }
                }
                sr.Close();
            }
            catch (Exception ex)
            {
                System.Windows.Forms.MessageBox.Show(ex.Message);
            }
            return true;
        }
 private void SetFocusPoint(FocusPoint pFocusPoint)
 {
     _previousFocusObject = _focusPoint;
     _focusPoint          = pFocusPoint;
 }
Beispiel #15
0
        private void GazeTimerTick(object sender, EventArgs e)
        {
            if (GazeSource.DataTimeStamp == LastSampleTime)
            {
                return;
            }

            System.Windows.Point controlPointOnScreen = FocusPoint.PointToScreen(new System.Windows.Point(FocusPoint.Width / 2, FocusPoint.Height / 2));
            var gazeRectangle = new Rectangle((int)controlPointOnScreen.X, (int)controlPointOnScreen.Y, 0, 0);

            gazeRectangle.Inflate(300, 300);

            if (!gazeRectangle.Contains(GazeSource.DataPoint))
            {
                return;
            }

            if (GazeSource.DataTimeStamp - LastSampleTime > TimeSpan.FromSeconds(1))
            {
                DataPoints.Clear();
            }

            DataPoints.Add(GazeSource.DataPoint);
            LastSampleTime = GazeSource.DataTimeStamp;
            if (DataPoints.Count == 100)
            {
                double x = DataPoints.Skip(DataPoints.Count / 2).Average(p => p.X);
                double y = DataPoints.Skip(DataPoints.Count / 2).Average(p => p.Y);
                DataPoints.Clear();
                AverageDataPoints[DataPointIndex] = new PointF((float)x, (float)y);
                DataPointIndex++;

                TimeoutTimer.Stop();
                TimeoutTimer.Start();

                switch (DataPointIndex)
                {
                case 1:
                    ClearFocusPointLocation();
                    Canvas.SetRight(FocusPoint, 0);
                    Canvas.SetTop(FocusPoint, 0);
                    break;

                case 2:
                    ClearFocusPointLocation();
                    Canvas.SetRight(FocusPoint, 0);
                    Canvas.SetBottom(FocusPoint, 0);
                    break;

                case 3:
                    ClearFocusPointLocation();
                    Canvas.SetLeft(FocusPoint, 0);
                    Canvas.SetBottom(FocusPoint, 0);
                    break;

                case 4:
                    GazeSource.SetCalibrationPoints(AverageDataPoints[0], AverageDataPoints[1], AverageDataPoints[2], AverageDataPoints[3]);
                    Close();
                    break;
                }
            }
        }
Beispiel #16
0
 public void ViewMainMonitor()
 {
     fS             = mainMonitor.GetComponent <FocusPoint>();
     changePosition = true;
 }
Beispiel #17
0
 // Start is called before the first frame update
 void Start()
 {
     fS             = consoleScreen.GetComponent <FocusPoint>();
     changePosition = true;
 }