private void createUI()
        {
            visualizeGrid = AddControl <StateField>();
            {
                visualizeGrid.OffText = "Visualize Grid";
                visualizeGrid.OnText  = "This grid is currently being visualized by ''";

                visualizeGrid.onAdd += (object sender) =>
                {
                    // Create a object
                    GameObject go = new GameObject(target.name + " (Visual Grid)");

                    // Add the view
                    GridView view = go.AddComponent <GridView>();

                    view.visualizeGrid = grid;
                };
                visualizeGrid.onPing += (object sender) =>
                {
                    // Find the view
                    GridView view = GridView.findViewForGrid(grid);

                    // Ping in hierarchy
                    if (view != null)
                    {
                        EditorGUIUtility.PingObject(view.gameObject);
                    }
                };
            }

            visualizePath = AddControl <StateField>();
            {
                visualizePath.OffText = "Visualize Path";
                visualizePath.OnText  = "Paths are currently being visualized by ''";

                visualizePath.onAdd += (object sender) =>
                {
                    // Create a object
                    GameObject go = new GameObject(target.name + " (Visual Path)");

                    // Add the view
                    PathView view = go.AddComponent <PathView>();

                    view.visualizeGrid = grid;
                };
                visualizePath.onPing += (object sender) =>
                {
                    // Find the view
                    PathView view = PathView.findViewForGrid(grid);

                    // Ping in hierarchy
                    if (view != null)
                    {
                        EditorGUIUtility.PingObject(view.gameObject);
                    }
                };
            }

            AddControl <Spacer>();
        }
Esempio n. 2
0
    public static PathView Load()
    {
        PathView view = UIView.Load("Views/PathView", OverriddenViewController.Instance.transform) as PathView;

        view.name = "PathView";
        return(view);
    }
Esempio n. 3
0
        public MainForm(IDataLoader dataLoader)
        {
            if (dataLoader == null)
            {
                throw new ArgumentNullException("Invalid data loader.");
            }

            this._dataLoader = dataLoader;

            this.InitializeComponent();

            this._tabView  = new TabView(this.tab);
            this._pathView = new PathView(this.pathContainer);
            this._itemList = new ItemList(this.list);
            this._itemView = new ItemView(this.listView);

            this._tabView.IndexChanged  += this.OnCategoryChanged;
            this._itemList.ItemSelected += this.OnItemSelected;
            this._itemView.ItemSelected += this.OnProperySelected;

            this._mruMenu = new MruStripMenu(this.menuRecentFile, this.OnMruFile, MRU_REG_KEY + "\\RecentFiles", false);
            this._mruMenu.LoadFromRegistry();
            this.CheckRecentFiles();

            if (this._mruMenu.GetFiles().Length > 0)
            {
                this.OnMruFile(0, this._mruMenu.GetFileAt(0));
            }
        }
        public override void OnRender()
        {
            base.OnRender();

            // Check for visual components
            PathView pathView = PathView.findViewForGrid(grid);
            GridView gridView = GridView.findViewForGrid(grid);

            // Check for view
            if (pathView == null)
            {
                visualizePath.State = false;
            }
            else
            {
                visualizePath.OnText = string.Format("Paths visualized by '{0}'", pathView.gameObject.name);
                visualizePath.State  = true;
            }

            // Check for grid
            if (gridView == null)
            {
                visualizeGrid.State = false;
            }
            else
            {
                visualizeGrid.OnText = string.Format("Grid visualized by '{0}'", gridView.gameObject.name);
                visualizeGrid.State  = true;
            }
        }
        protected override void Update(float dt)
        {
            Vector3 zero = Vector3.zero;

            for (EntityRenderNode entityRenderNode = this.nodeList.Head; entityRenderNode != null; entityRenderNode = entityRenderNode.Next)
            {
                Vector3                 vector             = zero;
                SmartEntity             smartEntity        = (SmartEntity)entityRenderNode.Entity;
                GameObjectViewComponent gameObjectViewComp = smartEntity.GameObjectViewComp;
                StateComponent          stateComp          = smartEntity.StateComp;
                EntityState             rawState           = stateComp.RawState;
                if (rawState == EntityState.Moving)
                {
                    PathView pathView = smartEntity.PathingComp.PathView;
                    if (pathView != null)
                    {
                        pathView.TimeOnPathSegment += dt;
                        vector = this.entityRenderController.MoveGameObject(gameObjectViewComp, pathView, smartEntity.SizeComp.Width);
                    }
                }
                if (rawState != EntityState.Dying)
                {
                    this.entityRenderController.RotateGameObject(smartEntity, vector.x, vector.z, dt);
                }
                else if (smartEntity.TroopComp != null)
                {
                    gameObjectViewComp.UpdateAllAttachments();
                }
                if (smartEntity.TroopComp != null || smartEntity.DroidComp != null)
                {
                    bool isAbilityModeActive = smartEntity.TroopComp != null && smartEntity.TroopComp.IsAbilityModeActive;
                    this.entityRenderController.UpdateAnimationState(gameObjectViewComp, stateComp, isAbilityModeActive);
                }
            }
        }
Esempio n. 6
0
    public override IView Create(ViewTypes type)
    {
        IView view = null;
        switch (type) {
            case ViewTypes.EDITOR_LANDING:
                view = new EditorView(services.ViewService);
                break;
            case ViewTypes.EDITOR_PATH:
                view = new PathView((services as EditorServices).PathService, services.ViewService);
                break;
            case ViewTypes.EDITOR_EDIT_PATH:
                view = new EditPathView((services as EditorServices).PathService, services.ViewService);
                break;
            case ViewTypes.EDITOR_LEVELS:
                view = new LevelsView((services as EditorServices).LevelService, services.ViewService,
                    (services as EditorServices).PathService, (services as EditorServices).EnemyService,
                    (services as EditorServices).BonusService, (services as EditorServices).DifficultyService);
                break;
            case ViewTypes.EDITOR_EDIT_LEVEL:
                view = new EditLevelView(services.Pool,
                    (services as EditorServices).LevelService,
                    services.ViewService,
                    (services as EditorServices).PathService,
                    (services as EditorServices).EnemyService);
                break;
            case ViewTypes.EDITOR_EDIT_ENEMY:
                view = new EditEnemyView(services.Pool, services.ViewService, (services as EditorServices).EnemyService);
                break;
            case ViewTypes.EDITOR_ENEMIES:
                view = new EnemiesView(services.Pool, services.ViewService, (services as EditorServices).EnemyService);
                break;
            case ViewTypes.EDITOR_EDIT_DIFFICULTY:
                view = new EditDifficultyView(services.Pool, services.ViewService, (services as EditorServices).DifficultyService);
                break;
            case ViewTypes.EDITOR_DIFFICULTIES:
                view = new DifficultiesView(services.Pool, services.ViewService, (services as EditorServices).DifficultyService);
                break;
            case ViewTypes.EDITOR_EDIT_BONUS:
                view = new EditBonusView(services.Pool, services.ViewService, (services as EditorServices).BonusService);
                break;
            case ViewTypes.EDITOR_BONUSES:
                view = new BonusesView(services.Pool, services.ViewService, (services as EditorServices).BonusService);
                break;
            case ViewTypes.EDITOR_EDIT_LANGUAGE:
                view = new EditLanguageView(services.Pool, services.ViewService, (services as EditorServices).LanguageService);
                break;
            case ViewTypes.EDITOR_LANUGAGES:
                view = new LanguagesView(services.Pool, services.ViewService, (services as EditorServices).LanguageService);
                break;
        }
        if (view == null) {
            view = base.Create(type);
        }
        else {
            initView(view);
        }

        return view;
    }
Esempio n. 7
0
        public bool StartAttack()
        {
            int    num            = 0;
            Target targetToAttack = this.shooterController.GetTargetToAttack(this.Entity);

            if (this.Entity.TroopComp != null && this.Entity.TroopComp.TroopShooterVO.TargetSelf)
            {
                return(this.SetState(this.WarmupState));
            }
            if (this.StateComponent.CurState == EntityState.Moving)
            {
                PathView           pathView = this.Entity.PathingComp.PathView;
                BoardCell <Entity> nextTurn = pathView.GetNextTurn();
                BoardCell <Entity> prevTurn = pathView.GetPrevTurn();
                if (prevTurn != null)
                {
                    this.lastLookAtX = nextTurn.X - prevTurn.X;
                    this.lastLookAtZ = nextTurn.Z - prevTurn.Z;
                }
            }
            int x = targetToAttack.TargetBoardX - this.TransformComponent.CenterGridX();
            int y = targetToAttack.TargetBoardZ - this.TransformComponent.CenterGridZ();

            if (this.lastLookAtX != 0 || this.lastLookAtZ != 0)
            {
                int num2 = IntMath.Atan2Lookup(this.lastLookAtX, this.lastLookAtZ);
                int num3 = IntMath.Atan2Lookup(x, y);
                int num4 = (num2 > num3) ? (num2 - num3) : (num3 - num2);
                if (num4 > 16384)
                {
                    num4 = 32768 - num4;
                }
                WalkerComponent walkerComp = this.Entity.WalkerComp;
                if (walkerComp != null)
                {
                    long num5 = (long)walkerComp.SpeedVO.RotationSpeed * 16384L;
                    if (num5 > 0L)
                    {
                        num  = (int)((long)num4 * 3142L * 1000L / num5);
                        num *= 2;
                    }
                }
            }
            this.lastLookAtX = x;
            this.lastLookAtZ = y;
            bool result;

            if (num > 0)
            {
                this.TurnState.SetDefaultLockDuration((uint)num);
                result = this.SetState(this.TurnState);
            }
            else
            {
                result = this.SetState(this.WarmupState);
            }
            return(result);
        }
Esempio n. 8
0
    public void ClickPrepare()
    {
        PrepareSplashImage.Deactivate();
        PrepareButton.Deactivate();
        DeactivateTimer();
        ActivateTip(0);

        UIViewController.ActivateUIView(PathView.Load());
        UIViewController.ActivateUIView(PositionView.Load());
    }
Esempio n. 9
0
    protected override void OnCleanUp()
    {
        base.OnCleanUp();

        PathItem.clickPath         -= ClickedPath;
        PositionItem.clickPosition -= ClickedPosition;

        Instance = null;

        //Debug.Log("OnCleanup PathView");
    }
Esempio n. 10
0
        /// <summary>
        /// Attempts to search this grid for a path between the start and end points.
        /// </summary>
        /// <param name="start">The <see cref="Index"/> into the search space representing the start position</param>
        /// <param name="end">The <see cref="Index"/> into the search space representing the end position</param>
        /// <param name="diagonal">The diagonal mode used when finding paths</param>
        /// <param name="callback">The <see cref="PathRequestDelegate"/> method to call whe the algorithm has completed</param>
        public void findPath(Index start, Index end, DiagonalMode diagonal, PathRequestDelegate callback)
        {
            // Make sure the grid is ready
            if (verifyReady() == false)
            {
                callback(null, PathRequestStatus.GridNotReady);
                return;
            }

            // Update max path length
            searchGrid.maxPathLength = maxPathLength;

            // Get the threading value
            bool useThreading = allowThreading;

#if UNITY_WEBGL
            // Threading is not allowed on web gl platform
            useThreading = false;
#endif

            // Check if threading is enabled
            if (useThreading == true)
            {
                // Create a request
                AsyncPathRequest request = new AsyncPathRequest(searchGrid, start, end, diagonal, (Path path, PathRequestStatus status) =>
                {
#if UNITY_EDITOR
                    // Pass the path for rendering before it is used by the caller otherwise nodes may be removed from the path
                    PathView.setRenderPath(this, path);
#endif
                    // Invoke callback
                    callback(path, status);
                });

                // Dispatch the request
                ThreadManager.Active.asyncRequest(request);
            }
            else
            {
                PathRequestStatus status;

                // Run the task immediatley
                Path result = findPathImmediate(start, end, out status, diagonal);

#if UNITY_EDITOR
                // Pass the path for rendering before it is used by the caller otherwise nodes may be removed
                PathView.setRenderPath(this, result);
#endif

                // Trigger callback
                callback(result, status);
            }
        }
Esempio n. 11
0
 public void InitializePathView()
 {
     if (this.PathView == null)
     {
         this.PathView = new PathView(this);
     }
     else
     {
         this.PathView.Reset(this);
     }
     this.PathView.AdvanceNextTurn();
 }
Esempio n. 12
0
        protected override void Update(uint dt)
        {
            Board board = Service.BoardController.Board;

            for (MovementNode movementNode = this.nodeList.Head; movementNode != null; movementNode = movementNode.Next)
            {
                SmartEntity smartEntity = (SmartEntity)movementNode.Entity;
                if (smartEntity.StateComp.CurState == EntityState.Moving && smartEntity.PathingComp.CurrentPath != null)
                {
                    smartEntity.PathingComp.TimeOnSegment += dt;
                    if ((ulong)smartEntity.PathingComp.TimeOnSegment > (ulong)((long)smartEntity.PathingComp.TimeToMove))
                    {
                        BoardCell boardCell = smartEntity.PathingComp.GetNextTile();
                        if (boardCell == null)
                        {
                            if (smartEntity.DroidComp == null)
                            {
                                Service.ShooterController.StopMoving(smartEntity.StateComp);
                            }
                            Service.EventManager.SendEvent(EventId.TroopReachedPathEnd, smartEntity);
                            smartEntity.PathingComp.CurrentPath = null;
                        }
                        else
                        {
                            smartEntity.TransformComp.X = boardCell.X;
                            smartEntity.TransformComp.Z = boardCell.Z;
                            board.MoveChild(smartEntity.BoardItemComp.BoardItem, smartEntity.TransformComp.CenterGridX(), smartEntity.TransformComp.CenterGridZ(), null, false, false);
                            PathView  pathView = smartEntity.PathingComp.PathView;
                            BoardCell nextTurn = pathView.GetNextTurn();
                            if (nextTurn.X == boardCell.X && nextTurn.Z == boardCell.Z)
                            {
                                pathView.AdvanceNextTurn();
                            }
                            boardCell = smartEntity.PathingComp.AdvanceNextTile();
                            if (boardCell != null)
                            {
                                bool flag = smartEntity.TransformComp.X != boardCell.X && smartEntity.TransformComp.Z != boardCell.Z;
                                smartEntity.PathingComp.TimeToMove += ((!flag) ? 1000 : 1414) * smartEntity.PathingComp.TimePerBoardCellMs / 1000;
                            }
                            else
                            {
                                DefenderComponent defenderComp = smartEntity.DefenderComp;
                                if (defenderComp != null)
                                {
                                    defenderComp.Patrolling = false;
                                }
                            }
                        }
                    }
                }
            }
        }
Esempio n. 13
0
    public void ClickRole(int roleIndex)
    {
        SoundManager.Instance.PlaySoundEffect(SoundType.BUTTON_CLICK);

        Avatar.Instance.Role = (PieceRole)roleIndex;
        if ((PieceRole)roleIndex == PieceRole.OFFENSE)
        {
            UIViewController.ActivateUIView(PathView.Load());
            State = RoleViewState.PATH;
        }
        else
        {
            UIViewController.ActivateUIView(PositionView.Load());
            State = RoleViewState.POSITION;
        }
        PrepareSplashImage.Deactivate();
    }
Esempio n. 14
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            SetContentView(Resource.Layout.tracker_main_widget);

            m_permissionsManager = new PermissionsManager(this);
            m_permissionsManager.RequestPermissions();

            m_locationManager = new GpsLocationManager(this);

            m_eventConnectionManager = new EventsConnectionManager(m_locationManager, m_locationBuffer, this);

            m_pathView = FindViewById <PathView>(Resource.Id.path_view);

            m_wakeLock = new WakeLockWrapper(this);
        }
Esempio n. 15
0
    protected override void OnInit()
    {
        base.OnInit();

        if (Instance == null)
        {
            Instance = this;

            PathItem.clickPath         += ClickedPath;
            PositionItem.clickPosition += ClickedPosition;

            //Debug.Log("OnInit PathView instance created");
        }
        else
        {
            Destroy(gameObject);

            //Debug.Log("OnInit PathView instance exists");
        }
    }
Esempio n. 16
0
        public Vector3 MoveGameObject(GameObjectViewComponent view, PathView pathView, int troopWidth)
        {
            BoardCell <Entity> nextTurn = pathView.GetNextTurn();

            if (nextTurn != null && pathView.TimeToTarget > 0f)
            {
                float num  = 0f;
                float num2 = 0f;
                pathView.GetTroopClusterOffset(ref num, ref num2);
                float   num3     = Mathf.Min(pathView.TimeOnPathSegment / pathView.TimeToTarget, 1f);
                Vector3 startPos = pathView.StartPos;
                float   num4     = (Units.BoardToWorldX(nextTurn.X) - startPos.x) * num3 + startPos.x + num;
                float   num5     = (Units.BoardToWorldX(nextTurn.Z) - startPos.z) * num3 + startPos.z + num2;
                num4 += Units.BoardToWorldX((float)troopWidth / 2f);
                num5 += Units.BoardToWorldX((float)troopWidth / 2f);
                Transform mainTransform = view.MainTransform;
                Vector3   result        = new Vector3(num4 - mainTransform.position.x, 0f, num5 - mainTransform.position.z);
                view.SetXYZ(num4, mainTransform.position.y, num5);
                return(result);
            }
            return(Vector3.zero);
        }
Esempio n. 17
0
        /// <summary>
        /// Attempts to find a <see cref="Path"/> between the start and end points and returns the result on completion.
        /// </summary>
        /// <param name="start">The <see cref="Index"/> into the search space representing the start position</param>
        /// <param name="end">The <see cref="Index"/> into the search space representing the end position</param>
        /// <param name="status">The <see cref="PathRequestStatus"/> describing the state of the result</param>
        /// <param name="diagonal">The diagonal mode used when finding a path</param>
        /// <returns>The <see cref="Path"/> that was found or null if the algorithm failed</returns>
        public Path findPathImmediate(Index start, Index end, out PathRequestStatus status, DiagonalMode diagonal)
        {
            // Make sure the grid is ready
            if (verifyReady() == false)
            {
                status = PathRequestStatus.GridNotReady;
                return(null);
            }

            // Update max path length
            searchGrid.maxPathLength = maxPathLength;

            // Store a temp path
            Path path = null;
            PathRequestStatus temp = PathRequestStatus.InvalidIndex;

            // Find a path
            searchGrid.findPath(start, end, diagonal, (Path result, PathRequestStatus resultStatus) =>
            {
                // Store the status
                temp = resultStatus;

                // Make sure the path was found
                if (resultStatus == PathRequestStatus.PathFound)
                {
                    path = result;

#if UNITY_EDITOR
                    PathView.setRenderPath(this, path);
#endif
                }
            });

            status = temp;
            return(path);
        }
        private string Write148_PathView(PathView v)
        {
            switch (v)
            {
                case PathView.ShowNormalRootName:
                    return "ShowNormalRootName";

                case PathView.ShowShortRootName:
                    return "ShowShortRootName";

                case PathView.ShowIconForEveryFolder:
                    return "ShowIconForEveryFolder";

                case PathView.ShowActiveState:
                    return "ShowActiveState";

                case PathView.ShowDriveMenuOnHover:
                    return "ShowDriveMenuOnHover";

                case PathView.VistaLikeBreadcrumb:
                    return "VistaLikeBreadcrumb";

                case PathView.ShowFolderIcon:
                    return "ShowFolderIcon";
            }
            return XmlSerializationWriter.FromEnum((long) v, new string[] { "ShowNormalRootName", "ShowShortRootName", "ShowIconForEveryFolder", "ShowActiveState", "ShowDriveMenuOnHover", "VistaLikeBreadcrumb", "ShowFolderIcon" }, new long[] { 0L, 1L, 2L, 4L, 8L, 0x10L, 0x20L }, "Nomad.FileSystem.Virtual.PathView");
        }
Esempio n. 19
0
    IEnumerator CheckBattleStatus()
    {
        yield return(StartCoroutine(OnlineManager.Instance.StartGetGame()));

        PathManager.Instance.Initialize();

        if (OnlineManager.Instance.GameStatus == OnlineGameStatus.PREPARING)
        {
            State = RoleViewState.ROLE;
            bool selectionAlreadyMade = false;
            //Debug.Log(Avatar.Instance.Role + " " + Avatar.Instance.Path + " " + Avatar.Instance.Path.Points + " " + Avatar.Instance.Path.Points.Count);
            if (Avatar.Instance.Role == PieceRole.OFFENSE && Avatar.Instance.Path != null && Avatar.Instance.Path.Points != null && Avatar.Instance.Path.Points.Count > 1)
            {
                State = RoleViewState.PATH_SELECTED;
                selectionAlreadyMade = true;
            }
            else if (Avatar.Instance.Role == PieceRole.DEFENSE && Avatar.Instance.Path != null && Avatar.Instance.Path.Points != null && Avatar.Instance.Path.Points.Count == 1)
            {
                State = RoleViewState.POSITION_SELECTED;
                selectionAlreadyMade = true;
            }
            //Debug.Log(selectionAlreadyMade);
            if (selectionAlreadyMade)
            {
                PreparedSplashImage.Activate();
                SelectButton.ButtonIconImage.sprite = ChangePositionButtonSprite;
                SelectButton.Activate();

                UIViewController.ActivateUIView(PathView.Load());
                UIViewController.ActivateUIView(PositionView.Load());

                if (State == RoleViewState.PATH_SELECTED)
                {
                    UnselectPositions();
                    PathView.Instance.ActivateExistingPath();
                }
                else
                {
                    UnselectPaths();
                    PositionView.Instance.ActivateExistingPosition();
                }

                DisablePathAndPositionSelection();

                ActivateTimer();
                MoveTimerUp();
            }
            else
            {
                SelectButton.Deactivate();

                PrepareSplashImage.Activate();
                PrepareButton.Activate();

                ActivateTimer();
            }

            // calculate time
            _nextBattleDateTime = DateTime.Parse(OnlineManager.Instance.GameData.scheduled_start);
            //Debug.Log(_nextBattleDateTime);
            SetTimeText();
            //Debug.Log(timeToNextBattle);

            RefreshButton.Activate();
            enabled = true;
        }
        else
        {
            SelectButton.Deactivate();
            PrepareSplashImage.Deactivate();
            PreparedSplashImage.Activate();
        }
        BackButton.Activate();
    }