コード例 #1
0
    public static void Initialize()
    {
        _cachedCommander = PlayerManager.MainController.Commander;
        GridBuilder.Initialize();

        OrganizerStructures = LSUtility.CreateEmpty().transform;
        OrganizerStructures.transform.parent = PlayerManager.MainController.Commander.GetComponentInChildren <RTSAgents>().transform;
        OrganizerStructures.gameObject.name  = "OrganizerStructures";

        WallPositioningHelper.Initialize();

        UserInputHelper.OnSingleLeftTapDown  += HandleSingleLeftClick;
        UserInputHelper.OnSingleRightTapDown += HandleSingleRightClick;
    }
コード例 #2
0
ファイル: Move.cs プロジェクト: pharazone/Lockstep-Framework
    public override void Initialize(LSAgent agent)
    {
        MyMovementGroupID = -1;

        Body            = agent.Body;
        Body.Mover      = this;
        Body.OnContact += HandleCollision;


        Turner = agent.GetAbility <Turn> ();

        timescaledSpeed = ((Speed * LockstepManager.Timestep) >> FixedMath.SHIFT_AMOUNT);
        closingDistance = agent.Body.Radius;

        RepathCount       = LSUtility.GetRandom(RepathRate);
        ViableDestination = false;
    }
コード例 #3
0
        void OnGUI()
        {
            GUI.matrix = Matrix4x4.TRS(new Vector3(0, 0, 0), Quaternion.identity, new Vector3(2.5f, 2.5f, 1));



            if (GUILayout.Button("Restart"))
            {
                ReplayManager.Stop();
                LSUtility.LoadLevel(SceneManager.GetActiveScene().name);
            }

            if (GUILayout.Button("Playback"))
            {
                LastSave = ReplayManager.SerializeCurrent();
                LSUtility.LoadLevel(SceneManager.GetActiveScene().name);
                ReplayManager.Play(LastSave);
            }
        }
コード例 #4
0
    void Start()
    {
        LockstepManager.Initialize();
        GridManager.Generate();
        const int count = 32;


        for (int i = -count; i < count; i++)
        {
            for (int j = -count; j < count; j++)
            {
                if (i * i + j * j < 16)
                {
                    continue;
                }
                if (LSUtility.GetRandom(2) == 0)
                {
                    Vector2d pos = new Vector2d(i, j);
                    GridManager.GetNode(pos.x, pos.y).Unwalkable = true;
                    Instantiate(TestWall).GetComponent <LSBody>().Initialize(pos);
                }
            }
        }

        /*LSBody wall = Instantiate (TestWall).GetComponent<LSBody> ();
         * wall.Initialize (new Vector2d (-32 + 14, 0));
         * for (long i = wall.XMin; i <= wall.XMax; i+= FixedMath.One) {
         *      for (long j = wall.YMin; j <= wall.YMax; j+= FixedMath.One) {
         *              GridManager.GetNode (i, j).Unwalkable = true;
         *      }
         * }*/

        GridManager.Initialize();
        controller = AgentController.Create();
        for (int i = 0; i < 256; i++)
        {
            agent = controller.CreateAgent(AgentCode.Minion);
        }
        PlayerManager.AddAgentController(controller);
    }
コード例 #5
0
        private void DistributeCollision()
        {
            if (!DoPhysics)
            {
                return;
            }

            switch (LeCollisionType)
            {
            case CollisionType.Circle_Circle:
                DistX = Body1._position.x - Body2._position.x;
                DistY = Body1._position.y - Body2._position.y;
                dist  = FixedMath.Sqrt((DistX * DistX + DistY * DistY) >> FixedMath.SHIFT_AMOUNT);

                if (dist == 0)
                {
                    //If objects are on the same position, give them push in random direction
                    const long randomMax = FixedMath.One / 32;
                    Body1._position.x    += LSUtility.GetRandomLong(randomMax) - randomMax / 2;
                    Body1._position.y    += LSUtility.GetRandomLong(randomMax) - randomMax / 2;
                    Body1.PositionChanged = true;
                    Body2._position.x    += LSUtility.GetRandomLong(randomMax) - randomMax / 2;
                    Body2._position.y    += LSUtility.GetRandomLong(randomMax) - randomMax / 2;
                    Body2.PositionChanged = true;
                    return;
                }


                depth = (Body1.Radius + Body2.Radius - dist);

                if (depth <= 0)
                {
                    return;
                }
                DistX = (DistX * depth / dist);
                DistY = (DistY * depth / dist);

                //Resolving collision


                if (Body1.Immovable || (Body2.Immovable == false && Body1.Priority > Body2.Priority))
                {
                    DistX *= -1;
                    DistY *= -1;
                    DistributeCircle_CirclePriority(Body1, Body2);
                }
                else if (Body2.Immovable || Body2.Priority > Body1.Priority)
                {
                    DistributeCircle_CirclePriority(Body2, Body1);
                }
                else
                {
                    DistX /= 2;
                    DistY /= 2;
                    DistributeCircle(Body1);
                    DistX *= -1;
                    DistY *= -1;
                    DistributeCircle(Body2);
                }
                break;

            case CollisionType.Circle_AABox:
                if (Body1.Shape == ColliderType.AABox)
                {
                    DistributeCircle_Box(Body1, Body2);
                }
                else
                {
                    DistributeCircle_Box(Body2, Body1);
                }
                break;

            case CollisionType.Circle_Polygon:
                if (Body1.Shape == ColliderType.Circle)
                {
                    this.DistributeCircle_Poly(Body1, Body2);
                }
                else
                {
                    this.DistributeCircle_Poly(Body2, Body1);
                }
                break;
            }
        }
コード例 #6
0
 public static void Initialize()
 {
     OrganizerWalls = LSUtility.CreateEmpty().transform;
     OrganizerWalls.transform.parent = ConstructionHandler.OrganizerStructures;
     OrganizerWalls.gameObject.name  = "OrganizerWalls";
 }