예제 #1
0
    public List <StarNode> GetNeighbors(StarNode node)
    {
        List <StarNode> Neighbors = new List <StarNode>();

        for (int x = -1; x <= 1; x++)
        {
            for (int y = -1; y <= 1; y++)
            {
                if (x == 0 && y == 0)
                {
                    continue;
                }

                int checkX = node.GridX + x;
                int checkY = node.GridY + y;

                if (checkX >= 0 && checkX < GridSizeX && checkY >= 0 && checkY < GridSizeY)
                {
                    Neighbors.Add(grid[checkX, checkY]);
                }
            }
        }

        return(Neighbors);
    }
        public void Visit(StarNode node)
        {
            var right = Nodes.Pop();
            var left  = Nodes.Pop();

            Nodes.Push(new StarNode(left, right));
        }
예제 #3
0
 public static void loadStarSystem(StarNode star)
 {
     Debug.Log("loading star system");
     gameManager._starNodes.destroy();
     SceneLoader.LoadByIndex(3);
     gameManager.selectedStar = star;
     UnityEngine.SceneManagement.SceneManager.sceneLoaded += onStarLoaded;
 }
예제 #4
0
        public Fleet makeFleet(Faction faction, StarNode parent, Vector3 position)
        {
            var fleet = _makeFleet(faction, parent, position, "fleet" + faction.state.fleets.Count);

            shipFactory.makeShip(fleet, position + new Vector3(1, 0, 0));
            shipFactory.makeShip(fleet, position + new Vector3(2, 0, 0));
            shipFactory.makeShip(fleet, position + new Vector3(3, 0, 0));
            parent.enterable.addFleet(fleet);
            return(fleet);
        }
예제 #5
0
        private Fleet makeTransforms(StarNode starAt, out GameObject go)
        {
            go = new GameObject("fleet");
            var fleet = go.AddComponent <Fleet>();

            go.SetParent(starAt.state.positionState.appearTransform);
            // var collider = fleet.gameObject.AddComponent<BoxCollider>();
            //collider.size = new Vector3(3, 3, 3);
            return(fleet);
        }
예제 #6
0
        private Fleet _makeFleet(Faction faction, StarNode starAt, Vector3 position, string name)
        {
            GameObject fleetGo;
            var        fleet         = makeTransforms(starAt, out fleetGo);
            var        fleetState    = makeFleetState(fleet, position, faction, fleetGo.transform, starAt, name);
            var        fleetRenderer = makeAppearers(fleetState);

            fleet.init(fleetState, fleetRenderer);
            faction.state.fleets[fleet.state.id] = fleet;
            fleetGo.name = fleet.name;

            return(fleet);
        }
예제 #7
0
    int GetDistance(StarNode NodeA, StarNode NodeB)
    {
        int DstX = Mathf.Abs(NodeA.GridX - NodeB.GridX);
        int DstY = Mathf.Abs(NodeA.GridY - NodeB.GridY);

        if (DstX > DstY)
        {
            return(14 * DstY + 10 * (DstX - DstY));
        }
        else
        {
            return(14 * DstX + 10 * (DstY - DstX));
        }
    }
예제 #8
0
    void createGrid()
    {
        grid = new StarNode[GridSizeX, GridSizeY];
        Vector3 worldButtomLeft = transform.position - Vector3.right * gridWorldSizes.x / 2 - Vector3.forward * gridWorldSizes.y / 2;

        for (int x = 0; x < GridSizeX; x++)
        {
            for (int y = 0; y < GridSizeY; y++)
            {
                Vector3 worldpoint = worldButtomLeft + Vector3.right * (x * nodeDiameter + NodeRadius) + Vector3.forward * (y * nodeDiameter + NodeRadius);
                bool    walkable   = !Physics.CheckSphere(worldpoint, NodeRadius, UnwalkableMask);
                grid[x, y] = new StarNode(walkable, worldpoint, x, y);
            }
        }
    }
예제 #9
0
    Vector3[] RetracePath(StarNode StartNode, StarNode EndNode)
    {
        List <StarNode> Path = new List <StarNode>();

        StarNode CurrentNode = EndNode;

        while (CurrentNode != StartNode)
        {
            Path.Add(CurrentNode);
            CurrentNode = CurrentNode.NodeParent;
        }
        Vector3[] Waypoints = SimplifyPath(Path);
        Array.Reverse(Waypoints);

        return(Waypoints);
    }
예제 #10
0
    public void set(StarConnection starConnection)
    {
        starNode = GameManager.instance.selectedStar;
        if (starNode == null)
        {
            Debug.Log("starNode not found in starconnection");
        }
        if (starConnection.state.nodes[0] == starNode)
        {
            other = starConnection.state.nodes[1];
        }
        else
        {
            other = starConnection.state.nodes[0];
        }
        var name = other.name;

        text.text = name;
    }
예제 #11
0
        public void TestGetAdjacent()
        {
            // Create two nodes.
            var nodeA = new StarNode();
            var nodeB = new StarNode();

            // Attempt to attach at position 0 of node A.
            var attachResult = nodeA.Attach(nodeB, 0);

            Assert.IsTrue(attachResult);

            // Verify they are attached.
            Assert.AreEqual(nodeB, nodeA.GetAdjacent(0));
            Assert.AreEqual(nodeA, nodeB.GetAdjacent(StarNode.GetOppositePosition(0)));

            // Create a third node.
            var nodeC = new StarNode();

            // Attempt to attach at position 0 and verify it fails.
            attachResult = nodeA.Attach(nodeC, 0);
            Assert.IsFalse(attachResult);
        }
예제 #12
0
 public override void Visit(StarNode node)
 {
     ReportReturnTypesAreNotSame(node, "Star");
 }
예제 #13
0
 void Awake()
 {
     manager = GetComponentInParent <GameManager>();
     star    = GetComponentInParent <StarNode>();
 }
예제 #14
0
        private void CheckNodeObjects(SystemObject obj)
        {
            var currentParent = ExtractParents(obj);

            if (currentParent.Ring.HasValue)
            {
                var parentnode = _nodes.Where(m => m.BodyId == currentParent.Ring).FirstOrDefault();
                var childnode  = _nodes.Where(m => m.BodyId == obj.Id).FirstOrDefault();

                if (parentnode == null)
                {
                    parentnode = new RingNode(currentParent.Ring.Value);
                    _nodes.Add(parentnode);
                }

                if (childnode == null)
                {
                    childnode = SystemNode.CreateNodeFromObject(obj);
                    _nodes.Add(childnode);
                }

                parentnode.ChildList.Add(childnode);
                childnode.ParentList.Add(parentnode);

                UpdateStarsystemMap?.Invoke(childnode);

                return;
            }

            if (currentParent.Planet.HasValue)
            {
                var parentnode = _nodes.Where(m => m.BodyId == currentParent.Planet).FirstOrDefault();
                var childnode  = _nodes.Where(m => m.BodyId == obj.Id).FirstOrDefault();

                if (parentnode == null)
                {
                    parentnode = new PlanetNode(currentParent.Planet.Value);
                    _nodes.Add(parentnode);
                }

                if (childnode == null)
                {
                    childnode = SystemNode.CreateNodeFromObject(obj);
                    _nodes.Add(childnode);
                }

                parentnode.ChildList.Add(childnode);
                childnode.ParentList.Add(parentnode);

                UpdateStarsystemMap?.Invoke(childnode);

                return;
            }

            if (currentParent.Star.HasValue)
            {
                var parentnode = _nodes.Where(m => m.BodyId == currentParent.Star).FirstOrDefault();
                var childnode  = _nodes.Where(m => m.BodyId == obj.Id).FirstOrDefault();

                if (parentnode == null)
                {
                    parentnode = new StarNode(currentParent.Star.Value);
                    _nodes.Add(parentnode);
                }

                if (childnode == null)
                {
                    childnode = SystemNode.CreateNodeFromObject(obj);
                    _nodes.Add(childnode);
                }


                parentnode.ChildList.Add(childnode);
                childnode.ParentList.Add(parentnode);

                UpdateStarsystemMap?.Invoke(childnode);

                return;
            }

            if (currentParent.Null.HasValue)
            {
                var parentnode = _nodes.Where(m => m.BodyId == currentParent.Null).FirstOrDefault();
                var childnode  = _nodes.Where(m => m.BodyId == obj.Id).FirstOrDefault();

                if (parentnode == null)
                {
                    parentnode = new BarycenterNode(currentParent.Null.Value);
                    _nodes.Add(parentnode);
                }

                if (childnode == null)
                {
                    childnode = SystemNode.CreateNodeFromObject(obj);
                    _nodes.Add(childnode);
                }

                parentnode.ChildList.Add(childnode);
                childnode.ParentList.Add(parentnode);

                UpdateStarsystemMap?.Invoke(childnode);

                return;
            }
        }
예제 #15
0
 public AppearablePositionState(Transform appearTransform, Vector3 position, StarNode star, bool isActive = false) : this(appearTransform, position, Quaternion.identity, star, isActive)
 {
 }
예제 #16
0
 public AppearablePositionState(Transform appearTransform, Vector3 position, Quaternion rotation, StarNode star, bool isActive = false)
 {
     this.appearTransform          = appearTransform;
     this.isActive                 = isActive;
     this.starAt                   = (Reference <StarNode>)star;
     this.position                 = position;
     this.rotation                 = rotation;
     this.appearTransform.position = position;
 }
예제 #17
0
 public void loadStarSystem(StarNode star)
 {
     SceneLoader.loadStarSystem(star);
 }
예제 #18
0
        private RdlSyntaxNode ComposeArithmeticOperators(Precendence precendence)
        {
            RdlSyntaxNode node = null;

            switch (precendence)
            {
            case Precendence.Level1:
            {
                node = ComposeArithmeticOperators(Precendence.Level2);
                while (IsArithmeticOperator(Current, Precendence.Level1))
                {
                    switch (Current.TokenType)
                    {
                    case StatementType.Star:
                        Consume(StatementType.Star);
                        node = new StarNode(node, ComposeBaseTypes());
                        break;

                    case StatementType.FSlash:
                        Consume(StatementType.FSlash);
                        node = new FSlashNode(node, ComposeBaseTypes());
                        break;

                    case StatementType.Mod:
                        Consume(StatementType.Mod);
                        node = new ModuloNode(node, ComposeBaseTypes());
                        break;

                    case StatementType.In:
                        Consume(StatementType.In);
                        node = new InNode(node, ComposeArgs());
                        break;

                    case StatementType.NotIn:
                        Consume(StatementType.NotIn);
                        node = new NotInNode(node, ComposeArgs());
                        break;
                    }
                }
                break;
            }

            case Precendence.Level2:
            {
                node = ComposeArithmeticOperators(Precendence.Level3);
                while (IsArithmeticOperator(Current, Precendence.Level2))
                {
                    switch (Current.TokenType)
                    {
                    case StatementType.Plus:
                        Consume(StatementType.Plus);
                        node = new AddNode(node, ComposeBaseTypes());
                        break;

                    case StatementType.Hyphen:
                        Consume(StatementType.Hyphen);
                        node = new HyphenNode(node, ComposeBaseTypes());
                        break;
                    }
                }
                break;
            }

            case Precendence.Level3:
                node = ComposeBaseTypes();
                break;
            }
            return(node);
        }
예제 #19
0
 /// <summary>
 ///     Performs "Star" specific operations.
 /// </summary>
 /// <param name="node">The "Star" node.</param>
 public virtual void Visit(StarNode node)
 {
     Instructions.Add(new MultiplyNumerics());
 }
예제 #20
0
    IEnumerator FindPath(Vector3 StartPosition, Vector3 TargetPosition)
    {
        Stopwatch sw = new Stopwatch();

        sw.Start();

        Vector3[] Waypoints     = new Vector3[0];
        bool      IsPathSuccess = false;


        StarNode StartNode  = Gird.GetNodeFromWorldPoint(StartPosition);
        StarNode TargetNode = Gird.GetNodeFromWorldPoint(TargetPosition);

        if (StartNode.IsWalkable && TargetNode.IsWalkable)
        {
            Heap <StarNode>    OpenSet   = new Heap <StarNode>(Gird.MaxSize);
            HashSet <StarNode> ClosedSet = new HashSet <StarNode>();

            OpenSet.Add(StartNode);

            while (OpenSet.Count > 0)
            {
                StarNode CurrentNode = OpenSet.RemoveFirst();
                ClosedSet.Add(CurrentNode);

                if (CurrentNode == TargetNode)
                {
                    sw.Stop();
                    print("Path found: " + sw.ElapsedMilliseconds + " ML");
                    IsPathSuccess = true;

                    break;
                }

                foreach (StarNode Neighbor in Gird.GetNeighbors(CurrentNode))
                {
                    if (!Neighbor.IsWalkable || ClosedSet.Contains(Neighbor))
                    {
                        continue;
                    }

                    int NewMovementCostToNeighour = CurrentNode.Gcost + GetDistance(CurrentNode, Neighbor);
                    if (NewMovementCostToNeighour < Neighbor.Gcost || !OpenSet.Contains(Neighbor))
                    {
                        Neighbor.Gcost      = NewMovementCostToNeighour;
                        Neighbor.Hcost      = GetDistance(Neighbor, TargetNode);
                        Neighbor.NodeParent = CurrentNode;

                        if (!OpenSet.Contains(Neighbor))
                        {
                            OpenSet.Add(Neighbor);
                            OpenSet.UpdateItem(Neighbor);
                        }
                    }
                }
            }
        }


        yield return(null);

        if (IsPathSuccess)
        {
            Waypoints = RetracePath(StartNode, TargetNode);
        }

        RequestManager.FinshedProcessingPath(Waypoints, IsPathSuccess);
    }
예제 #21
0
	// the constructor for child nodes
	public StarNode(Vector3 NewPosition, StarNode ParentNode, Vector3 TargetPosition) {
		Position = NewPosition;
		ScoreG = ParentNode.ScoreG;
		// Test this later, by giving more score to down movements
		//Vector3 MovementDistance = Position - ParentNode.Position;
		ScoreG ++;	// add a higher score for movement
		CalculateScoreH (TargetPosition);
	}
예제 #22
0
	// Checks the surrounding nodes for the lowest FScore
	// TargetPosition is used to calculate H Score inside the constructor
	public StarNode AddNextNode(float Movement, Vector3 TargetPosition) 
	{
		StarNode NodeRight = new StarNode (Position + new Vector3 (Movement, 0, 0), this, TargetPosition);
		StarNode NodeLeft = new StarNode (Position + new Vector3 (-Movement, 0, 0), this, TargetPosition);
		StarNode NodeForward = new StarNode (Position + new Vector3 (0, 0, Movement), this, TargetPosition);
		StarNode NodeBack = new StarNode (Position + new Vector3 (0, 0, -Movement), this, TargetPosition);

		// Put a check here, if Position of node is equal to an obstacle, put its score as Math.Infinity so it never becomes the node

		/*Debug.LogError ("NodeRight: " + NodeRight.Position + " - Score: " + NodeRight.ScoreF().ToString());
		Debug.LogError ("NodeLeft: " + NodeLeft.Position + " - Score: " + NodeLeft.ScoreF().ToString());
		Debug.LogError ("NodeForward: " + NodeForward.Position + " - Score: " + NodeForward.ScoreF().ToString());
		Debug.LogError ("NodeBack: " + NodeBack.Position + " - Score: " + NodeBack.ScoreF().ToString());
		*/
		PossibleNextNodes.Clear ();
		NextNode = NodeRight;
		PossibleNextNodes.Add (NextNode);
		AddNextNode (NextNode, NodeLeft);
		AddNextNode (NextNode, NodeForward);
		AddNextNode (NextNode, NodeBack);

		NextNode = PossibleNextNodes [Random.Range (0,PossibleNextNodes.Count-1)];
		PossibleNextNodes.Clear ();
		return NextNode;
	}
예제 #23
0
 public void Visit(StarNode node)
 {
 }
예제 #24
0
	public StarNode CalculatePath(Vector3 Begin, Vector3 End) {
		StarNode BeginNode = new StarNode (Begin, End);
		StarNode CurrentNode = BeginNode;

		for (int i = 0; i < 1000; i++) 
		{
			//Debug.LogError ("NodePosition: " + CurrentNode.Position + " - Score: " + CurrentNode.ScoreF().ToString());
			CurrentNode = CurrentNode.AddNextNode(1, End);
			//Debug.LogError ("NextNodePosition: " + CurrentNode.Position + " - Score: " + CurrentNode.ScoreF().ToString());

			// if Found a path return it
			if (CurrentNode.Position == End)
				return BeginNode;
			//i = 1000;	// debug break
			//Debug.Break();
		}
		return null;
	}
예제 #25
0
	// checks both nodes to see which one is closer to the target position using the FScore
	void AddNextNode(StarNode PossibleNode1, StarNode PossibleNode2) {
		/*if (PossibleNode1.ScoreF () < PossibleNode2.ScoreF ()) {
			//NextNode = PossibleNode1;
			//PossibleNextNodes.Clear();
			//PossibleNextNodes.Add (NextNode);
		} 
		else */
		if (PossibleNode1.ScoreF () == PossibleNode2.ScoreF ()) {
			PossibleNextNodes.Add (PossibleNode2);
		}
		else if (PossibleNode1.ScoreF () < PossibleNode2.ScoreF ()){
			NextNode = PossibleNode2;
			PossibleNextNodes.Add (NextNode);
		}
	}
 public void Visit(StarNode node)
 {
     node.Left.Accept(this);
     node.Right.Accept(this);
     node.Accept(_visitor);
 }
예제 #27
0
 /// <summary>
 ///     Visit Star node.
 /// </summary>
 /// <param name="node">Star node of AST</param>
 public abstract void Visit(StarNode node);
        public override void PresentStep(int index, PresentationViewController presentationViewController)
        {
            switch (index)
            {
            case 0:
                TextManager.SetSubtitle("Built-in parametric primitives");
                break;

            case 1:
                PresentPrimitives();
                break;

            case 2:
                // Hide the carousel and illustrate SCNText
                TextManager.FlipOutText(SlideTextManager.TextType.Subtitle);

                SCNTransaction.Begin();
                SCNTransaction.AnimationDuration = 1.0f;
                SCNTransaction.SetCompletionBlock(() => {
                    if (CarouselNode != null)
                    {
                        CarouselNode.RemoveFromParentNode();
                    }
                });

                PresentTextNode();

                TextNode.Opacity = 1.0f;

                if (CarouselNode != null)
                {
                    CarouselNode.Position = new SCNVector3(0, CarouselNode.Position.Y, -50);
                    CarouselNode.Opacity  = 0.0f;
                }

                SCNTransaction.Commit();

                TextManager.SetSubtitle("Built-in 3D text");
                TextManager.AddBulletAtLevel("SCNText", 0);
                TextManager.FlipInText(SlideTextManager.TextType.Subtitle);
                TextManager.FlipInText(SlideTextManager.TextType.Bullet);
                break;

            case 3:
                //Show bezier path
                var star = StarPath(3, 6);

                var shape = SCNShape.Create(star, 1);
                shape.ChamferRadius  = 0.2f;
                shape.ChamferProfile = OutlineChamferProfilePath();
                shape.ChamferMode    = SCNChamferMode.Front;

                // that way only the outline of the model will be visible
                var outlineMaterial = SCNMaterial.Create();
                outlineMaterial.Ambient.Contents  = outlineMaterial.Diffuse.Contents = outlineMaterial.Specular.Contents = NSColor.Black;
                outlineMaterial.Emission.Contents = NSColor.White;
                outlineMaterial.DoubleSided       = true;

                var tranparentMaterial = SCNMaterial.Create();
                tranparentMaterial.Transparency = 0.0f;

                shape.Materials = new SCNMaterial[] {
                    tranparentMaterial,
                    tranparentMaterial,
                    tranparentMaterial,
                    outlineMaterial,
                    outlineMaterial
                };

                StarOutline          = SCNNode.Create();
                StarOutline.Geometry = shape;
                StarOutline.Position = new SCNVector3(0, 5, 30);
                StarOutline.RunAction(SCNAction.RepeatActionForever(SCNAction.RotateBy(0, (float)Math.PI * 2, 0, 10.0)));

                GroundNode.AddChildNode(StarOutline);

                // Hide the 3D text and introduce SCNShape
                SCNTransaction.Begin();
                SCNTransaction.AnimationDuration = 1;
                SCNTransaction.SetCompletionBlock(() => {
                    TextNode.RemoveFromParentNode();
                });

                TextManager.FlipOutText(SlideTextManager.TextType.Subtitle);
                TextManager.FlipOutText(SlideTextManager.TextType.Bullet);

                TextManager.SetSubtitle("3D Shapes");

                TextManager.AddBulletAtLevel("SCNShape", 0);

                TextManager.FlipInText(SlideTextManager.TextType.Subtitle);
                TextManager.FlipInText(SlideTextManager.TextType.Bullet);
                TextManager.FlipInText(SlideTextManager.TextType.Code);

                StarOutline.Position = new SCNVector3(0, 5, 0);
                TextNode.Position    = new SCNVector3(TextNode.Position.X, TextNode.Position.Y, -30);


                SCNTransaction.Commit();
                break;

            case 4:
                star = StarPath(3, 6);

                shape = SCNShape.Create(star, 0);
                shape.ChamferRadius = 0.1f;

                StarNode          = SCNNode.Create();
                StarNode.Geometry = shape;
                var material = SCNMaterial.Create();
                material.Reflective.Contents = new NSImage(NSBundle.MainBundle.PathForResource("SharedTextures/color_envmap", "png"));
                material.Diffuse.Contents    = NSColor.Black;
                StarNode.Geometry.Materials  = new SCNMaterial[] { material };
                StarNode.Position            = new SCNVector3(0, 5, 0);
                StarNode.Pivot = SCNMatrix4.CreateTranslation(0, 0, -0.5f);
                StarOutline.ParentNode.AddChildNode(StarNode);

                StarNode.EulerAngles = StarOutline.EulerAngles;
                StarNode.RunAction(SCNAction.RepeatActionForever(SCNAction.RotateBy(0, (float)Math.PI * 2, 0, 10.0)));

                SCNTransaction.Begin();
                SCNTransaction.AnimationDuration = 1.0f;
                SCNTransaction.SetCompletionBlock(() => {
                    StarOutline.RemoveFromParentNode();
                });

                shape.ExtrusionDepth = 1;
                StarOutline.Opacity  = 0.0f;

                SCNTransaction.Commit();
                break;

            case 5:
                //OpenSubdiv
                TextManager.FlipOutText(SlideTextManager.TextType.Subtitle);
                TextManager.FlipOutText(SlideTextManager.TextType.Bullet);

                TextManager.SetSubtitle("Subdivisions");

                TextManager.AddBulletAtLevel("OpenSubdiv", 0);
                TextManager.AddCode("#aGeometry.#SubdivisionLevel# = anInteger;#");

                TextManager.FlipInText(SlideTextManager.TextType.Subtitle);
                TextManager.FlipInText(SlideTextManager.TextType.Bullet);
                TextManager.FlipInText(SlideTextManager.TextType.Code);

                //add boxes
                var boxesNode = SCNNode.Create();

                var level0 = Utils.SCAddChildNode(boxesNode, "rccarBody_LP", "Scenes.scnassets/car/car_lowpoly", 10);
                level0.Position = new SCNVector3(-6, level0.Position.Y, 0);

                var label = Utils.SCBoxNode("0", new CGRect(0, 0, 40, 40), NSColor.Orange, 20.0f, true);
                label.Position = new SCNVector3(0, -35, 10);
                label.Scale    = new SCNVector3(0.3f, 0.3f, 0.001f);
                level0.AddChildNode(label);

                boxesNode.Position = new SCNVector3(0, 0, 30);

                var level1 = level0.Clone();

                /*foreach (var child in level1.ChildNodes) {
                 *      if (child.Name != "engine_LP") {
                 *              child.Geometry = (SCNGeometry)child.Geometry.Copy ();
                 *              child.Geometry.SubdivisionLevel = 3;
                 *      }
                 * }*/

                level1.Position = new SCNVector3(6, level1.Position.Y, 0);
                boxesNode.AddChildNode(level1);

                label          = Utils.SCBoxNode("2", new CGRect(0, 0, 40, 40), NSColor.Orange, 20.0f, true);
                label.Position = new SCNVector3(0, -35, 10);
                label.Scale    = new SCNVector3(0.3f, 0.3f, 0.001f);
                level1.AddChildNode(label);

                level0.RunAction(SCNAction.RepeatActionForever(SCNAction.RotateBy((float)Math.PI * 2, new SCNVector3(0, 1, 0), 45.0)));
                level1.RunAction(SCNAction.RepeatActionForever(SCNAction.RotateBy((float)Math.PI * 2, new SCNVector3(0, 1, 0), 45.0)));

                SCNTransaction.Begin();
                SCNTransaction.AnimationDuration = 1;
                SCNTransaction.SetCompletionBlock(() => {
                    StarNode.RemoveFromParentNode();
                });

                // move the camera back to its previous position
                presentationViewController.CameraNode.Position  = new SCNVector3(0, 0, 0);
                presentationViewController.CameraPitch.Rotation = new SCNVector4(1, 0, 0, Pitch * (float)Math.PI / 180.0f);

                StarNode.Position    = new SCNVector3(StarNode.Position.X, StarNode.Position.Y, StarNode.Position.Z - 30);
                StarOutline.Position = new SCNVector3(StarOutline.Position.X, StarOutline.Position.Y, StarOutline.Position.Z - 30);

                GroundNode.AddChildNode(boxesNode);

                //move boxes in
                boxesNode.Position = new SCNVector3(0, 0, 3.5f);

                SCNTransaction.Commit();
                break;
            }
        }
예제 #29
0
        private FleetState makeFleetState(Fleet fleet, Vector3 position, Faction faction, Transform appearTransform, StarNode star, string name)
        {
            var positionState = new AppearablePositionState(
                position: position,
                appearTransform: appearTransform,
                star: star
                );

            return(new FleetState(
                       ships: new ShipsContainer()
            {
                onEmpty = () => {
                    Debug.Log("destroying fleet");
                    positionState.starAt.value.enterable.removeFleet(fleet);
                    GameManager.idMaker.removeObject(fleet.state.id);
                    UnityEngine.MonoBehaviour.Destroy(fleet.gameObject);
                }
            },
                       id: GameManager.idMaker.newId(fleet),
                       icon: icon,
                       stamp: new FactoryStamp(),
                       namedState: new Galaxy.State.NamedState(name),
                       positionState: positionState,
                       actionState: new SelfStateActionState(fleet),
                       factionOwnedState: new FactionOwnedState {
                belongsTo = (Reference <Faction>)faction
            }
                       ));
        }