Ejemplo n.º 1
0
    protected override void Start()
    {
        base.Start();

        GetAllCapturePoints();

        // Utility AI setup

        // ****** VALUES ******
        UAIV_AgentHealth              agentHealth              = new UAIV_AgentHealth(this, _AgentController._AgentStats.HealthPoints);
        UAIV_SoldierFriendlyCount     friendlySoldierCount     = new UAIV_SoldierFriendlyCount(this, 4);
        UAIV_SoldierEnemyCount        enemySoldierCount        = new UAIV_SoldierEnemyCount(this, 3);
        UAIV_DistanceToEnemy          distanceToEnemy          = new UAIV_DistanceToEnemy(this, _AgentController._Senses._ViewRange);
        UAIV_DistanceToFriendlyFlag   distanceToFriendlyFlag   = new UAIV_DistanceToFriendlyFlag(this, _AgentController._Senses._ViewRange);
        UAIV_FriendlyFlagsCount       friendlyFlagsCount       = new UAIV_FriendlyFlagsCount(this, 5);
        UAIV_AllFriendlySoldiersCount allFriendlySoldiersCount = new UAIV_AllFriendlySoldiersCount(this, _AgentController._PlayerOwner._MaxSoldiers);

        // ****** SCORERS ******
        UtilityScorer scorer_agentHealth              = new UtilityScorer(agentHealth, _HealthCurve);
        UtilityScorer scorer_friendlyCount            = new UtilityScorer(friendlySoldierCount, _FriendlyAgentsCurve);
        UtilityScorer scorer_enemyCount               = new UtilityScorer(enemySoldierCount, _EnemyAgentsCurve);
        UtilityScorer scorer_distanceToEnemy          = new UtilityScorer(distanceToEnemy, _AttackDesireCurve);
        UtilityScorer scorer_distanceToEnemyFlee      = new UtilityScorer(distanceToEnemy, _FleeDesireCurve);
        UtilityScorer scorer_distanceToFriendlyFlag   = new UtilityScorer(distanceToFriendlyFlag, _FriendlyFlagDistanceCurve);
        UtilityScorer scorer_friendlyFlagsCount       = new UtilityScorer(friendlyFlagsCount, _FriendlyFlagsForHQAttackCurve);
        UtilityScorer scorer_allFriendlySoldiersCount = new UtilityScorer(allFriendlySoldiersCount, _AllFriendlyAgentsCountCurve);

        // ****** ACTIONS ******
        CaptureFlags captureFlagsAction = new CaptureFlags(capturePointsInScene, this, 0.5f);

        AttackEnemy attackEnemyAction = new AttackEnemy(this, 0.0f);

        attackEnemyAction.AddScorer(scorer_distanceToEnemy);

        Flee fleeAction = new Flee(this, 0.0f);

        fleeAction.AddScorer(scorer_agentHealth);
        fleeAction.AddScorer(scorer_enemyCount);
        fleeAction.AddScorer(scorer_friendlyCount);
        //fleeAction.AddScorer(scorer_distanceToEnemyFlee);

        HealAtFlag healAtFlagAction = new HealAtFlag(this, 0.0f);

        healAtFlagAction.AddScorer(scorer_agentHealth);
        healAtFlagAction.AddScorer(scorer_distanceToFriendlyFlag);
        healAtFlagAction.AddScorer(scorer_distanceToEnemyFlee);

        AttackHQ attackHQAction = new AttackHQ(_AgentController._PlayerOwner._EnemyPlayer, this, 0.0f);

        attackHQAction.AddScorer(scorer_friendlyFlagsCount);
        attackHQAction.AddScorer(scorer_allFriendlySoldiersCount);

        // ****** REGISTER ACTIONS ******
        _AgentActions.Add(captureFlagsAction);
        _AgentActions.Add(attackEnemyAction);
        _AgentActions.Add(fleeAction);
        _AgentActions.Add(healAtFlagAction);
        _AgentActions.Add(attackHQAction);
    }
Ejemplo n.º 2
0
        public static void TakeTempSnapshot(Action <string, bool> finishCallback, CaptureFlags captureFlags = CaptureFlags.NativeObjects | CaptureFlags.ManagedObjects)
        {
            string[] s           = Application.dataPath.Split('/');
            string   projectName = s[s.Length - 2];
            string   path        = Application.temporaryCachePath + "/" + projectName + ".snap";

            TakeSnapshot(path, finishCallback, captureFlags);
        }
Ejemplo n.º 3
0
        static void TestFlagConflict(CaptureFlags f, params CaptureFlags[] conflicting)
        {
            var matching = conflicting.Where(x => f.HasFlag(x)).ToArray();

            if (matching.Length > 1)
            {
                throw new ArgumentException($"flags {string.Join(", ", matching.Select(x => x.ToString()))} are not compatible");
            }
        }
Ejemplo n.º 4
0
        public static void TakeTempSnapshot(Action <string, bool> finishCallback, CaptureFlags captureFlags = CaptureFlags.ManagedObjects | CaptureFlags.NativeObjects)
        {
            string[] array = Application.dataPath.Split(new char[]
            {
                '/'
            });
            string str  = array[array.Length - 2];
            string path = Application.temporaryCachePath + "/" + str + ".snap";

            MemoryProfiler.TakeSnapshot(path, finishCallback, captureFlags);
        }
Ejemplo n.º 5
0
		internal static Byte[] CaptureWindow(nsIDOMWindow domWindow, CaptureFlags captureFlags = CaptureFlags.None)
		{
			var domWindowInternal = (nsIDOMWindowInternal)domWindow;

			nsIDOMHTMLCanvasElement canvas = GetCanvas(domWindowInternal.Document);
			canvas.Width = (UInt32)domWindowInternal.InnerWidth;// + domWindowInternal.ScrollMaxX;
			canvas.Height = (UInt32)domWindowInternal.InnerHeight;// + domWindowInternal.ScrollMaxY;

			DrawWindow(canvas, domWindow, Color.Empty, captureFlags);

			Byte[] imageData = GetImageData(canvas);
			return imageData;
		}
Ejemplo n.º 6
0
        public static CaptureFlags ParseFlags(IEnumerable <char> flagChars)
        {
            CaptureFlags flags = 0;

            foreach (var f in flagChars)
            {
                flags |= f switch {
                    '?' => CaptureFlags.Optional,
                    '>' => CaptureFlags.SkipDataLineIfNotFound,
                    '<' => CaptureFlags.SkipTemplateLineIfNotFound,
                    '|' => CaptureFlags.RepeatTemplateLineUntilNotFound,
                    _ => 0,
                };
            }
            TestFlagConflict(flags,
                             CaptureFlags.SkipDataLineIfNotFound,
                             CaptureFlags.SkipTemplateLineIfNotFound,
                             CaptureFlags.RepeatTemplateLineUntilNotFound);
            return(flags);
        }
Ejemplo n.º 7
0
        public static void TakeSnapshot(string path, Action <string, bool> finishCallback, Action <string, bool, DebugScreenCapture> screenshotCallback, CaptureFlags captureFlags = CaptureFlags.NativeObjects | CaptureFlags.ManagedObjects)
        {
            if (isCompiling)
            {
                Debug.LogError("Canceling snapshot, there is a compilation in progress.");
                return;
            }

            if (m_SnapshotFinished != null)
            {
                Debug.LogWarning("Canceling snapshot, there is another snapshot in progress.");
                finishCallback(path, false);
            }
            else
            {
                m_SnapshotFinished     += finishCallback;
                m_SaveScreenshotToDisk += screenshotCallback;
                StartOperation((uint)captureFlags, m_SaveScreenshotToDisk != null, path, false);
            }
        }
Ejemplo n.º 8
0
 public static void TakeSnapshot(string path, Action <string, bool> finishCallback, CaptureFlags captureFlags = CaptureFlags.NativeObjects | CaptureFlags.ManagedObjects)
 {
     TakeSnapshot(path, finishCallback, null, captureFlags);
 }
Ejemplo n.º 9
0
 public static void TakeTempSnapshot(Action <string, bool> finishCallback, CaptureFlags captureFlags = CaptureFlags.NativeObjects | CaptureFlags.ManagedObjects)
 {
 }
Ejemplo n.º 10
0
 public static void TakeSnapshot(string path, Action <string, bool> finishCallback, Action <string, bool, DebugScreenCapture> screenshotCallback, CaptureFlags captureFlags = CaptureFlags.NativeObjects | CaptureFlags.ManagedObjects)
 {
 }
        public static void TakeSnapshot(string path, Action <string, bool> finishCallback, CaptureFlags captureFlags = CaptureFlags.NativeObjects | CaptureFlags.ManagedObjects)
        {
            if (isCompiling)
            {
                Debug.LogError("Canceling snapshot, there is a compilation in progress.");
                return;
            }

            if (snapshotFinished != null)
            {
                Debug.LogWarning("Canceling snapshot, there is another snapshot in progress.");
                finishCallback(path, false);
            }
            else
            {
                snapshotFinished += finishCallback;
                TakeSnapshotInternal(path, (uint)captureFlags);
            }
        }
Ejemplo n.º 12
0
		private static void DrawWindow(nsIDOMHTMLCanvasElement canvasElement, nsIDOMWindow domWindow, Color bgColor, CaptureFlags captureFlags)
		{
			var context = (nsIDOMCanvasRenderingContext2D)canvasElement.GetContext("2d", JsVal.JSVAL_NULL);
			String cssBgColor = String.Format(CssColorFormatInfo.CurrentInfo, "{0:rgba}", bgColor);
			context.DrawWindow(domWindow, 0, 0, canvasElement.Width, canvasElement.Height, cssBgColor, (UInt32)captureFlags);
		}
 public static void TakeSnapshot(string path, Action <string, bool> finishCallback, CaptureFlags captureFlags = CaptureFlags.NativeObjects | CaptureFlags.ManagedObjects)
 {
     if (snapshotFinished != null)
     {
         Debug.LogWarning("Canceling taking the snapshot. There is already ongoing capture.");
         finishCallback(path, false);
     }
     else
     {
         snapshotFinished += finishCallback;
         TakeSnapshotInternal(path, (uint)captureFlags);
     }
 }
Ejemplo n.º 14
0
 public CaptureSection(Pattern pattern, IEnumerable <VariablePart> varPath, CaptureFlags flags)
 {
     Pattern = pattern;
     VarPath = varPath.ToList();
     Flags   = flags;
 }
Ejemplo n.º 15
0
        public static void TakeSnapshot(string path, Action <string, bool> finishCallback, Action <string, bool, DebugScreenCapture> screenshotCallback, CaptureFlags captureFlags = CaptureFlags.ManagedObjects | CaptureFlags.NativeObjects)
        {
            bool flag = MemoryProfiler.isCompiling;

            if (flag)
            {
                UnityEngine.Debug.LogError("Canceling snapshot, there is a compilation in progress.");
            }
            else
            {
                bool flag2 = MemoryProfiler.m_SnapshotFinished != null;
                if (flag2)
                {
                    UnityEngine.Debug.LogWarning("Canceling snapshot, there is another snapshot in progress.");
                    finishCallback(path, false);
                }
                else
                {
                    MemoryProfiler.m_SnapshotFinished     += finishCallback;
                    MemoryProfiler.m_SaveScreenshotToDisk += screenshotCallback;
                    MemoryProfiler.StartOperation((uint)captureFlags, MemoryProfiler.m_SaveScreenshotToDisk != null, path, false);
                }
            }
        }