Beispiel #1
0
        public void Enter(List <object> GenData = null)
        {
            //GameManager.I.ChangeGameState (new GameStates.ModularGameState()); // change to modular state
            System             = GenData.Find <ModularBuildingSystem> (true);       // create link to Modular building system
            ScopedObject       = GenData.Find <ModularPlacableObject>(true);        // link to scoped piece
            OnPlacedCallback   = GenData.Find <Delegates.GenericDataCallbak>(true); // set on place callback
            OnCanceledCallback = GenData.Find <System.Action <object[]> >(true);    // set on cancle callback
            CanPlaceCallback   = GenData.Find <System.Func <ModularPlacableObject, bool> >(true);

            // init extra data
            LocalVisualGrid = (LocalGridSystem)GenData.Find <LocalGridSystem>();            // set cached local visual grid

            if ((object)GenData.FindObject <PlaceObjectCache> () != null)
            {
                Cache = GenData.Find <PlaceObjectCache> ();                // set cache
            }
            else
            {
                InitDefaultValues();
            }

            Indicator = (Indicator != null)?Indicator:GameManager.I.Utils.NewLineIndicator(Vector3.zero, Vector3.zero); // set indicator if is null

            Init();                                                                                                     // initialize

            // init detail
            ScopedObject.SetCollidersActive(false, true);
            DetailSettings.OnValuesChanged = OnValueChanged;
            UpdateTransform();
        }
        public override void Connect(bool bRestore)
        {
            if (indicators == null)
            {
                FScene scene = GetScene();
                indicators = new SOSceneIndicatorSet(this, scene);

                LineIndicator line = new LineIndicator()
                {
                    LineWidth   = fDimension.Scene(0.5),
                    VisibleF    = () => { return(LineAlwaysVisible || SceneUtil.IsVisible(this)); },
                    SceneStartF = () => { return(MinPosS); },
                    SceneEndF   = () => { return(MaxPosS); },
                    LayerF      = () => { return(FPlatform.GeometryLayer); }
                };
                indicators.AddIndicator(line);

                SectionPlaneIndicator plane = new SectionPlaneIndicator()
                {
                    Width       = fDimension.Scene(() => { return(BoundsDim); }),
                    ColorF      = () => { return(Colorf.VideoYellow.WithAlpha(0.5f)); },
                    VisibleF    = () => { return(GetScene().IsSelected(this) || (active_gizmo != null && active_gizmo.IsCapturing)); },
                    SceneFrameF = () => {
                        Vector3f curPosS = GetLocalFrame(CoordSpace.SceneCoords).Origin;
                        return(new Frame3f(CenterPosS + (curPosS - MinPosS)));
                    }
                };
                indicators.AddIndicator(plane);
            }
        }
        internal List <CardModel> ParseOnDeployAutomaticSkillTarget(LineIndicator line, int slotNumber, SkillTarget target)
        {
            if (target == SkillTarget.CorrespondingEnemyLine)
            {
                return(_lines[(int)line.Opposite()]);
            }

            List <CardModel> cards = _lines[(int)line];

            if (target == SkillTarget.AllInLineExceptMe)
            {
                return(cards.GetAllExceptOne(slotNumber).ToList());
            }
            if (target == SkillTarget.LeftNeighbor)
            {
                return(cards.GetLeftNeighbor(slotNumber).ToList());
            }
            if (target == SkillTarget.BothNeighbors)
            {
                return(cards.GetBothNeighbors(slotNumber).ToList());
            }
            if (target == SkillTarget.RightNeighbor)
            {
                return(cards.GetRightNeighbor(slotNumber).ToList());
            }

            throw new Exception("Unreachable code reached! "
                                + "CardSkillTarget enumerator must have been extended without extending the ParseCardSkillTarget function.");
        }
Beispiel #4
0
 public MoveData(CardModel card, LineIndicator fromLine, int fromSlotNumber, LineIndicator targetLine, int targetSlotNumber)
 {
     Card             = card;
     FromLine         = fromLine;
     FromSlotNumber   = fromSlotNumber;
     TargetLine       = targetLine;
     TargetSlotNumber = targetSlotNumber;
 }
        private void IdeOverlaysCanvas_Draw(CanvasControl sender, CanvasDrawEventArgs args)
        {
            // Git diff indicators
            int i = 0;

            foreach (var modification in _DiffIndicators.Span)
            {
                switch (modification)
                {
                case LineModificationType.Modified:
                    DrawDiffMarker(args.DrawingSession, GetOffsetAt(i), ModifiedGitDiffMarkerStrokeColor, ModifiedGitDiffMarkerOutlineColor);
                    break;

                case LineModificationType.Saved:
                    DrawDiffMarker(args.DrawingSession, GetOffsetAt(i), SavedGitDiffMarkerStrokeColor, SavedGitDiffMarkerOutlineColor);
                    break;
                }

                i++;
            }

            // Indentation indicators
            i = 0;
            foreach (var indicator in _IndentationIndicators.Span)
            {
                if (!(indicator is null))
                {
                    // Manually perform the type checks and unsafe casts to skip
                    // the multiple null and type checking produced by the C# compiler
                    if (indicator.GetType() == typeof(FunctionIndicator))
                    {
                        FunctionIndicator function = Unsafe.As <FunctionIndicator>(indicator);

                        DrawFunctionDeclaration(args.DrawingSession, GetOffsetAt(i) + IndentationIndicatorsVerticalOffsetMargin, function.Type);
                    }
                    else if (indicator.GetType() == typeof(BlockIndicator))
                    {
                        BlockIndicator block = Unsafe.As <BlockIndicator>(indicator);

                        DrawIndentationBlock(args.DrawingSession, GetOffsetAt(i) + IndentationIndicatorsVerticalOffsetMargin, block.Depth, block.Type, block.IsWithinFunction);
                    }
                    else if (indicator.GetType() == typeof(LineIndicator))
                    {
                        LineIndicator line = Unsafe.As <LineIndicator>(indicator);

                        DrawLine(args.DrawingSession, GetOffsetAt(i) + IndentationIndicatorsVerticalOffsetMargin, line.Type);
                    }
                }

                i++;
            }

            // Breakpoints markers
            foreach (var pair in BreakpointIndicators)
            {
                DrawBreakpointIndicator(args.DrawingSession, pair.Value);
            }
        }
Beispiel #6
0
        List <SkillTargetData> GetTargetsOnDeployAutomatic(CardSkill skill, LineIndicator targetLine, int slotNumber)
        {
            var targets = new List <SkillTargetData>();

            foreach (SkillTarget target in skill.Targets)
            {
                targets.AddRange(ParseOnDeployAutomatic(targetLine, slotNumber, target));
            }

            return(targets);
        }
Beispiel #7
0
        // AI uses abstractions and requires mapping
        public MoveData(CardModel card, PlayerIndicator playerIndicator, int fromSlotNumber, PlayerLine targetLine, int targetSlotNumber)
        {
            Card       = card;
            FromLine   = playerIndicator == PlayerIndicator.Top ? LineIndicator.TopDeck : LineIndicator.BotDeck;
            TargetLine = playerIndicator == PlayerIndicator.Bot
                ? (LineIndicator)(5 - (int)targetLine)
                : (LineIndicator)(int)targetLine;

            FromSlotNumber   = fromSlotNumber;
            TargetSlotNumber = targetSlotNumber;
        }
        internal void ApplySkillEffectForAISingleTarget(CardSkill skill, LineIndicator targetLine, int slotNumber)
        {
            CardModel card = _lines[(int)targetLine][slotNumber];

            skill.Effect(card);

            BroadcastSkillEffect_LogUpdate(CurrentPlayer, new List <CardModel>(1)
            {
                card
            }, skill);
        }
Beispiel #9
0
 void Awake()
 {
     if (Instance == null)
     {
         Instance = this;
     }
     else
     {
         Destroy(this);
     }
 }
Beispiel #10
0
        private void CleanUp()
        {
            // HACK: 5.7. CleanUp
            RightMarginAdornment?.CleanUp();
            LineBreaksAdornment?.CleanUp();
            LineIndicator?.CleanUp();
            ColumnIndicator?.CleanUp();

            RightMarginAdornment = null;
            LineBreaksAdornment  = null;
            LineIndicator        = null;
            ColumnIndicator      = null;
        }
Beispiel #11
0
        public void MoveCardForUI(
            LineIndicator fromLine, int fromSlotNumber,
            LineIndicator targetLine, int targetSlotNumber,
            bool applySkill = true)
        {
            #region Assertions
#if UNITY_EDITOR || DEVELOPMENT_BUILD
            MoveDataAssertions(fromLine, fromSlotNumber, targetLine, targetSlotNumber);
#endif
            #endregion

            List <CardModel> fLine = _lines[(int)fromLine];
            List <CardModel> tLine = _lines[(int)targetLine];

            CardModel card = fLine[fromSlotNumber];
            card.SlotNumber  = targetSlotNumber;
            card.CurrentLine = targetLine;

            fLine.RemoveAt(fromSlotNumber);

            // all cards on the right must have their SlotNumber reduced by one
            fLine.AllOnTheRight(fromSlotNumber, c => c.SlotNumber--);
            tLine.AllOnTheRight(targetSlotNumber, c => c.SlotNumber++);

            if (targetSlotNumber == tLine.Count)
            {
                tLine.Add(card);
            }
            else
            {
                tLine.Insert(targetSlotNumber, card);
            }

            BroadcastCardMove_LogUpdate(CurrentPlayer, new MoveData(card, fromLine, fromSlotNumber, targetLine, targetSlotNumber));

            if (applySkill)
            {
                ApplySkillEffectIfAny(card, targetLine, targetSlotNumber);

                // it's important to evaluate strengths before RemoveDeadOnes is called
                // as we want our data match the upper logic's data
                // UI removes its elements later on
                List <List <int> > cardStrengths = GetCardStrengths();

                // remove dead ones
                RemoveDeadOnes();

                // inform upper logic about new strengths
                BroadcastUpdateStrength_StatusUpdate(cardStrengths);
            }
        }
Beispiel #12
0
        public virtual void Setup()
        {
            Func <Vector3f> centerPosF = () => { return((Vector3f)(snappedPointsS[0] + snappedPointsS[1]) * 0.5f); };

            centerPos = fPosition.Scene(centerPosF);

            fDimension textHeight = null;

            if (TextHeightDimensionType == DimensionType.VisualAngle)
            {
                textHeight = fDimension.VisualAngle(centerPos, TextHeightDimension);
            }
            else if (TextHeightDimensionType == DimensionType.SceneUnits)
            {
                textHeight = fDimension.Scene(() => { return(TextHeightDimension); });
            }
            else
            {
                textHeight = fDimension.World(() => { return(TextHeightDimension); });
            }

            Func <Vector3f> labelPosF = () => {
                Vector3f p = centerPos.ScenePoint;
                float    h = textHeight.SceneValuef;
                p += 0.5f * h * scene.ToSceneN(Vector3f.AxisY);
                return(p);
            };

            indicators = new ToolIndicatorSet(this, scene);
            LineIndicator diag = new LineIndicator()
            {
                VisibleF    = () => { return(Initialized); },
                SceneStartF = () => { return((Vector3f)snappedPointsS[0]); },
                SceneEndF   = () => { return((Vector3f)snappedPointsS[1]); },
                ColorF      = () => { return(Colorf.VideoRed); },
                LineWidth   = fDimension.VisualAngle(centerPos, 0.5f),
            };

            indicators.AddIndicator(diag);

            dimension = new TextLabelIndicator()
            {
                VisibleF       = () => { return(Initialized && ShowTextLabel); },
                ScenePositionF = labelPosF,
                TextHeight     = textHeight,
                DimensionTextF = () => { return(string.Format("{0:F4}", snappedPointsS[0].Distance(snappedPointsS[1]))); }
            };
            indicators.AddIndicator(dimension);
        }
Beispiel #13
0
        private void OnLayoutChanged(object sender, TextViewLayoutChangedEventArgs e)
        {
            if (!IsInitialized)
            {
                CleanUp();
                CreateAdornment();
                IsInitialized = true;
            }

            // HACK: 5.3. OnLayoutChanged. レイアウトの変更イベント
            RightMarginAdornment?.OnLayoutChanged(sender, e);
            LineBreaksAdornment?.OnLayoutChanged(sender, e);
            LineIndicator?.OnLayoutChanged(sender, e);
            ColumnIndicator?.OnLayoutChanged(sender, e);
        }
Beispiel #14
0
        List <SkillTargetData> ParseOnDeployAutomatic(LineIndicator line, int slotNumber, SkillTarget target)
        {
            var targets = new List <SkillTargetData>();
            List <CardModel> cards;

            // corresponding enemy line
            if (target == SkillTarget.CorrespondingEnemyLine)
            {
                cards = _gameLogic.GetLine(line.Opposite());
                for (int i = 0; i < cards.Count; i++)
                {
                    targets.Add(new SkillTargetData(line.Opposite(), i));
                }

                return(targets);
            }

            // our line
            if (target == SkillTarget.AllInLineExceptMe)
            {
                cards = _gameLogic.GetLine(line).GetAllExceptOne(slotNumber).ToList();
            }
            else if (target == SkillTarget.LeftNeighbor)
            {
                cards = _gameLogic.GetLine(line).GetLeftNeighbor(slotNumber).ToList();
            }
            else if (target == SkillTarget.BothNeighbors)
            {
                cards = _gameLogic.GetLine(line).GetBothNeighbors(slotNumber).ToList();
            }
            else if (target == SkillTarget.RightNeighbor)
            {
                cards = _gameLogic.GetLine(line).GetRightNeighbor(slotNumber).ToList();
            }
            else
            {
                throw new Exception("Unreachable code reached! "
                                    + "CardSkillTarget enumerator must have been extended without extending the ParseCardSkillTarget function.");
            }

            foreach (CardModel model in cards)
            {
                targets.Add(new SkillTargetData(line, model.SlotNumber));
            }

            return(targets);
        }
Beispiel #15
0
        void ApplySkillEffectIfAny(CardModel card, LineIndicator deployLine, int slotNumber)
        {
            CardSkill skill = DB[card.CardId].Skill;

            if (skill != null)
            {
                var targets = new List <CardModel>();

                foreach (SkillTarget target in skill.Targets)
                {
                    targets.AddRange(ParseOnDeployAutomaticSkillTarget(deployLine, slotNumber, target));
                }

                foreach (CardModel target in targets)
                {
                    skill.Effect(target);
                }

                BroadcastSkillEffect_LogUpdate(CurrentPlayer, targets, skill);
            }
        }
Beispiel #16
0
        void MoveDataAssertions(LineIndicator fromLine, int fromSlotNumber, LineIndicator targetLine, int targetSlotNumber)
        {
            if (fromSlotNumber < 0 || fromSlotNumber > _lines[(int)fromLine].Count)
            {
                throw new System.ArgumentOutOfRangeException(
                          "fromSlotNumber",
                          "FromSlotNumber cannot be lower than 0 or greater than the number of cards in the line.");
            }

            if (targetSlotNumber < 0 || targetSlotNumber > _lines[(int)targetLine].Count)
            {
                throw new System.ArgumentOutOfRangeException(
                          "targetSlotNumber",
                          "TargetSlotNumber cannot be lower than 0 or greater than the number of cards in the line.");
            }

            if (targetLine == LineIndicator.TopDeck || targetLine == LineIndicator.BotDeck)
            {
                throw new System.ArgumentException("Moving card to a deck is not allowed.");
            }

            if (fromLine == targetLine)
            {
                throw new System.ArgumentException("Moving card to the same line is not allowed.");
            }

            if ((fromLine == LineIndicator.BotDeck || fromLine == LineIndicator.BotBackline || fromLine == LineIndicator.BotFrontline)
                &&
                (targetLine == LineIndicator.TopDeck || targetLine == LineIndicator.TopBackline || targetLine == LineIndicator.TopFrontline))
            {
                throw new System.ArgumentException("Moving card from any bot line to any top line is not allowed.");
            }

            if ((fromLine == LineIndicator.TopDeck || fromLine == LineIndicator.TopBackline || fromLine == LineIndicator.TopFrontline)
                &&
                (targetLine == LineIndicator.BotDeck || targetLine == LineIndicator.BotBackline || targetLine == LineIndicator.BotFrontline))
            {
                throw new System.ArgumentException("Moving card from any top line to any bot line is not allowed.");
            }
        }
Beispiel #17
0
        internal void MoveCardForAI(PlayerIndicator player, MoveData moveData)
        {
            LineIndicator fromLine         = moveData.FromLine;
            int           fromSlotNumber   = moveData.FromSlotNumber;
            LineIndicator targetLine       = moveData.TargetLine;
            int           targetSlotNumber = moveData.TargetSlotNumber;

            #region Assertions
#if UNITY_EDITOR || DEVELOPMENT_BUILD
            MoveDataAssertions(fromLine, fromSlotNumber, targetLine, targetSlotNumber);
#endif
            #endregion

            List <CardModel> fLine = _lines[(int)fromLine];
            List <CardModel> tLine = _lines[(int)targetLine];

            CardModel card = fLine[fromSlotNumber];
            card.SlotNumber  = targetSlotNumber;
            card.CurrentLine = targetLine;

            // all cards on the right must have their SlotNumber reduced by one
            fLine.AllOnTheRight(fromSlotNumber, c => c.SlotNumber--);
            fLine.RemoveAt(fromSlotNumber);

            if (targetSlotNumber == tLine.Count)
            {
                tLine.Add(card);
            }
            else
            {
                tLine.Insert(targetSlotNumber, card);
                tLine.AllOnTheRight(targetSlotNumber, c => c.SlotNumber++);
            }

            BroadcastCardMove_LogUpdate(player, moveData);
        }
Beispiel #18
0
        public RadialMeasureTool(FScene scene, SceneObject target)
        {
            this.scene = scene;

            behaviors = new InputBehaviorSet();

            // TODO is this where we should be doing this??
            behaviors.Add(
                new RadialMeasureTool_MouseBehavior(scene.Context)
            {
                Priority = 5
            });
            //behaviors.Add(
            //    new RevolveTool_SpatialDeviceBehavior(scene.ActiveController) { Priority = 5 });

            // shut off transform gizmo
            scene.Context.TransformManager.PushOverrideGizmoType(TransformManager.NoGizmoType);

            scene.SelectionChangedEvent += Scene_SelectionChangedEvent;

            this.meshTarget = target as MeshSO;

            var boundsW = meshTarget.GetBoundingBox(CoordSpace.WorldCoords);

            measureHitPos = boundsW.Center;
            update_measurement();


            indicators = new ToolIndicatorSet(this, scene);
            TextLabelIndicator dimensionLabel = new TextLabelIndicator()
            {
                ScenePositionF = () => { return(displayPosS + 0.01f * Vector3f.AxisY); },
                TextHeight     = fDimension.Scene(0.05f),
                DimensionTextF = () => { return(" " + (curDimension * 100).ToString("F2") + "cm"); }
            };

            indicators.AddIndicator(dimensionLabel);
            CircleIndicator circle = new CircleIndicator()
            {
                SceneFrameF = () => { return(new Frame3f(circleCenterS)); },
                RadiusF     = () => { return((float)(curDimension * 0.5)); },
                ColorF      = () => { return(new Colorf(Colorf.VideoRed, 0.5f)); },
                LineWidth   = fDimension.Scene(0.001f)
            };

            indicators.AddIndicator(circle);
            LineIndicator diag = new LineIndicator()
            {
                SceneStartF = () => { return(maxStart); },
                SceneEndF   = () => { return(maxEnd); },
                ColorF      = () => { return(Colorf.VideoRed); },
                LineWidth   = fDimension.Scene(0.001f)
            };

            indicators.AddIndicator(diag);
            SectionPlaneIndicator section_plane = new SectionPlaneIndicator()
            {
                SceneFrameF = () => { return(new Frame3f(displayPosS)); },
                Width       = fDimension.Scene(() => { return((float)(curDimension * 1.5)); })
            };

            indicators.AddIndicator(section_plane);
        }
 public static LineIndicator Opposite(this LineIndicator line) => (LineIndicator)(5 - (int)line);
Beispiel #20
0
 internal List <CardModel> GetLine(LineIndicator line) => _lines[(int)line];
Beispiel #21
0
 private void OnSelectionChanged(object sender, EventArgs e)
 {
     // HACK: 5.5. OnSelectionChanged. 選択変更のイベント
     LineIndicator?.OnSelectionChanged(sender, e);
     ColumnIndicator?.OnSelectionChanged(sender, e);
 }
Beispiel #22
0
 private void OnPositionChanged(object sender, CaretPositionChangedEventArgs e)
 {
     // HACK: 5.2. OnPositionChanged. ポジションの変更イベント
     LineIndicator?.OnPositionChanged(sender, e);
     ColumnIndicator?.OnPositionChanged(sender, e);
 }
 public SkillTargetData(LineIndicator line, int slotNumber)
 {
     Line       = line;
     SlotNumber = slotNumber;
 }