Inheritance: MonoBehaviour
Ejemplo n.º 1
0
    void Awake()
    {
        Debug.Log("LEVEL MANAGE AWAKE - initalizing game");
        // Make self a publicly available singleton
        if (instance == null)
        {
            instance = this;
        }
        else if (instance != this)
        {
            Destroy(gameObject);
        }

        // Never destroy gameManager (on scene changes)
        DontDestroyOnLoad(gameObject);

        // Store reference to other manager intances
        terrainManager = GetComponent <TerrainManager>();
        uiManager      = GetComponent <UIManager>();

        // Two tanks managers
        if (GetComponents <TankManager>().Length != 2)
        {
            throw new UnityException("Game<anager must have exactly 2 TankManagers");
        }
        tank0Manager = GetComponents <TankManager>()[0];
        tank1Manager = GetComponents <TankManager>()[1];

        // Let other managers do the setup
        Setup();
    }
Ejemplo n.º 2
0
    private void Start()
    {
        terrain_manager = terrain_manager_game_object.GetComponent <TerrainManager>();
        drones          = GameObject.FindGameObjectsWithTag("Drone");
        terrain_manager = terrain_manager_game_object.GetComponent <TerrainManager>();

        scale     = 2;
        mapMatrix = ExtendMatrix(terrain_manager, scale);

        makeGraph(terrain_manager, mapMatrix);

        initID();
        int k = 0;

        foreach (GameObject drone in drones)
        {
            Vector3 startPos = drone.transform.position;
            Vector3 goalPos  = drone.GetComponent <DroneAI>().my_goal_object.transform.position;

            List <Node> path = Astar(startPos, goalPos);

            drone.GetComponent <DroneAI>().my_path = path;
            drone.GetComponent <DroneAI>().friends = drones;
            drone.GetComponent <DroneAI>().DroneID = k++;
            Color c = drone.GetComponent <DroneAI>().my_goal_object.GetComponent <Renderer>().material.color;
            //Debug.DrawLine(startPos, goalPos, Color.black, 100f);
            drawPath(path, c);
        }
    }
Ejemplo n.º 3
0
 // Use this for initialization
 void Start()
 {
     _inv            = InventoryHandler.Instance();
     _terrainManager = TerrainManager.Instance();
     _GUIManager     = GUIManager.Instance();
     _popupAction    = GameObject.Find("Popup Action");
 }
Ejemplo n.º 4
0
    public override void OnInspectorGUI()
    {
        if (!TerrainManager.HasValidTerrain())
        {
            GUILayout.Label("Create or load a map to continue...");
            return;
        }

        PathNode instance = (PathNode)target;

        GUILayout.Label(string.Concat("Node Index : ", instance.transform.GetSiblingIndex()), EditorStyles.boldLabel);

        GUILayout.Space(5f);

        if (GUILayout.Button("Select Path Object"))
        {
            GameObject parent = instance.transform.parent?.gameObject;
            if (parent == null)
            {
                Debug.LogError("This path node does not have a parent path object. All nodes should be parented to a GameObject with a PathData component");
                return;
            }

            Selection.activeGameObject = parent;

            Debug.Log("Path object selected");
        }
    }
Ejemplo n.º 5
0
    public override void OnInspectorGUI()
    {
        base.OnInspectorGUI();


        //DrawDefaultInspector();

        TerrainManager terrainMan = (TerrainManager)target;



        if (GUILayout.Button("Make default map"))
        {
            terrainMan.MakeDefaultMap();
        }
        if (GUILayout.Button("Generate Map") || terrainMan.AutoGen)
        {
            terrainMan.GenerateTerrain();
            //terrainMan.mesh = terrainMan.meshGen.mesh;
        }
        if (GUILayout.Button("Perlin Noise") || terrainMan.AutoPerlin)
        {
            terrainMan.MakePerlinMap();
        }

        if (GUILayout.Button("Voronoi Noise"))
        {
            terrainMan.GenerateVoronoiMap();
        }

        if (GUILayout.Button("Make Pressure Map"))
        {
            terrainMan.MakePressureMap();
        }
    }
Ejemplo n.º 6
0
    public void OnSetCell(CellValue cellValue, Cell cell)
    {
        Int3       u    = new Int3(cell.x, cell.y, cell.z);
        GameObject inst = null;

        if (cellInstances.TryGetValue(cell, out inst))
        {
            Destroy(inst);
            cellInstances.Remove(cell);

            // Clear this cell in ALL block managers. Since we don't readily know
            // which one was there before.
            foreach (var manager in groupBlockManagers.Values)
            {
                manager.Clear(u);
            }
        }

        if (cellValue.blockType != BlockShape.Empty)
        {
            // NOTE: Could be slightly smarter by seeing if current style/shape/direction is same..
            SpawnCellBlock(cellValue.blockType, cell, cellValue.direction, cellValue.style);
            // NOTE: We only use game objects for collision now. Eventually, we should
            // stop doing that as well, and create per-block combined collision
            // meshes.

            Matrix4x4 cellTransform =
                Matrix4x4.Translate(TerrainManager.GetCellCenter(cell))
                * Matrix4x4.Rotate(GetBlockDirectionAsQuaternion(cellValue.direction));
            GetBlockManager(cellValue).Set(u, cellTransform);
        }
    }
Ejemplo n.º 7
0
    public override void OnInspectorGUI()
    {
        if (!TerrainManager.HasValidTerrain())
        {
            GUILayout.Label("Create or load a map to continue...");
            return;
        }

        PathManager instance = (PathManager)target;

        GUILayout.Label("Path Creator", EditorStyles.boldLabel);

        GUILayout.Space(5f);

        Type = (PathType)EditorGUILayout.EnumPopup("Path Type", Type);

        if (GUILayout.Button("Create"))
        {
            RaycastHit rayHit;
            if (Physics.Raycast(SceneView.lastActiveSceneView.camera.ViewportPointToRay(new Vector3(0.5f, 0.5f, 1.0f)), out rayHit, Mathf.Infinity, 1 << 8))
            {
                PathManager.CreatePath(Type, rayHit.point);
                Debug.Log(string.Concat("Create a new ", Type, " path at ", rayHit.point));
            }
            else
            {
                Debug.Log("Look at the terrain to create a path");
            }
        }
    }
Ejemplo n.º 8
0
    public override void PickRandomTerrainSeed(RpcArgs args)
    {
        string         seedNumber = args.GetNext <string>();
        TerrainManager tm         = FindObjectOfType <TerrainManager>();

        tm.seed = seedNumber;
    }
Ejemplo n.º 9
0
    private void Start()
    {
        // get the drone controller
        m_Drone = GetComponent <DroneController>();
        friends = GameObject.FindGameObjectsWithTag("Drone");
        myIndex = -1;
        for (int idx = 0; idx < friends.Length; idx++)
        {
            if (friends[idx].transform == m_Drone.transform)
            {
                myIndex = idx;
                break;
            }
        }
        terrain_manager = terrain_manager_game_object.GetComponent <TerrainManager>();
        tInfo           = terrain_manager.myInfo;
        Vector3 start_pos = m_Drone.transform.position;
        Vector3 goal_pos  = my_goal_object.transform.position;

        mHighResMap = new HighResMap(ref tInfo, 1);
        AStar aster = new AStar(ref mHighResMap);
        int   i     = mHighResMap.get_i_index(transform.position.x);
        int   j     = mHighResMap.get_j_index(transform.position.z);
        int   iEnd  = mHighResMap.get_i_index(goal_pos.x);
        int   jEnd  = mHighResMap.get_j_index(goal_pos.z);

        tPath     = aster.ComputePath(i, j, iEnd, jEnd);
        mDecision = new DroneDecisionSimple(ref m_Drone, ref friends, ref mHighResMap, tPath);
        //status init
        ifMoveable = false;
        ifFinished = false;
    }
Ejemplo n.º 10
0
 void Start()
 {
     characterController      = GetComponent <NewCharacterController>();
     capsuleCollider          = GetComponent <CapsuleCollider>();
     unityCharacterController = GetComponent <CharacterController>();
     tm = FindObjectOfType <TerrainManager>();
 }
Ejemplo n.º 11
0
 public virtual void Awake()
 {
     isRotating = false;
     terrainManager = GameObject.Find("Map").GetComponent<TerrainManager>();
     animator = GetComponent<Animator>();
     rigidBody = GetComponent<Rigidbody>();
 }
Ejemplo n.º 12
0
    public static List <Vector3> RouteDataFromKML(string kmlPath, TerrainManager terrainManager, WGS84 limits)
    {
        double horizontalSize = limits.east - limits.west;
        double verticalSize   = limits.north - limits.south;

        List <Vector3> positions = new List <Vector3>();
        int            count     = 0;

        List <KMLPlacemark> placemarks = ReadKMLFile(kmlPath);

        foreach (KMLPlacemark item in placemarks)
        {
            if (item.Type == KMLPlacemark.PlacemarkType.ROUTE)
            {
                foreach (Vector2 value in item.RouteValues)
                {
                    double auxLong = value.x - limits.west;
                    double auxLat  = value.y - limits.south;

                    double calculatedX = terrainManager.width * auxLong / horizontalSize;
                    double calculatedY = terrainManager.height * auxLat / verticalSize;

                    float auxHeight = terrainManager.terrain.GetTexture().GetPixel((int)calculatedX, (int)calculatedY).r;
                    //Add 10% of maxHeight to unblock from model
                    float finalHeight = auxHeight * terrainManager.maxHeight * 1.1f;

                    positions.Add(new Vector3((float)calculatedX, finalHeight, (float)calculatedY));

                    count++;
                }
            }
        }
        return(positions);
    }
Ejemplo n.º 13
0
    public void CreatePathDebug(TerrainManager TerrainManager_, ja2.TerrainTile From, ja2.TerrainTile To)
    {
        if (actualTask != null)
            actualTask.Stop();

        actualTask = new utils.Task(CreatePathDebug_CoRo(TerrainManager_, From, To));
    }
Ejemplo n.º 14
0
    public void CreateGrid()
    {
        if (manager == null)
        {
            manager = GameObject.Find("TerrainManager").GetComponent <TerrainManager>();
        }
        myInfo = manager.myInfo;
        map    = new Node[myInfo.x_N, myInfo.z_N];
        bool    walkable;
        Vector3 pos;

        for (int i = 0; i < myInfo.x_N; i++)
        {
            for (int j = 0; j < myInfo.z_N; j++)
            {
                if (myInfo.traversability[i, j] > 0.5)
                {
                    walkable = false;
                }
                else
                {
                    walkable = true;
                }
                pos       = new Vector3(myInfo.get_x_pos(i), 0f, myInfo.get_z_pos(j));
                map[i, j] = new Node(walkable, pos, i, j);
            }
        }
    }
Ejemplo n.º 15
0
 // Use this for initialization
 void Start()
 {
     carbehaviour   = GameObject.FindGameObjectWithTag("Player").GetComponent <CarBehaviour>();
     terrainManager = GameObject.FindGameObjectWithTag("terrainManager").GetComponent <TerrainManager>();
     drt            = GameObject.FindGameObjectWithTag("Player").GetComponent <DRTStimulus>();
     setDefault();
 }
Ejemplo n.º 16
0
    private void Start()
    {
        pandaBT = GetComponent <PandaBehaviour>();
        rb      = GetComponent <Rigidbody>();

        // get the drone controller
        m_Drone         = GetComponent <DroneController>();
        terrain_manager = terrain_manager_game_object.GetComponent <TerrainManager>();

        friend_tag = gameObject.tag;
        if (friend_tag == "Blue")
        {
            enemy_tag = "Red";
        }
        else
        {
            enemy_tag = "Blue";
        }

        friends = GameObject.FindGameObjectsWithTag(friend_tag);
        enemies = GameObject.FindGameObjectsWithTag(enemy_tag);

        ball = GameObject.FindGameObjectWithTag("Ball");

        goalie = friends[0];
    }
Ejemplo n.º 17
0
    public override void OnLMB(Vector3 point)
    {
        //calcualte how high we lifted the mouse
        float delta = Input.mousePosition.y * 5 / Screen.height - _oldHeight;

        //for every selected point, change Track's heightmap,
        //update terrain in the current point and move the heightpoint object
        foreach (var hp in _currentSelectedPoints)
        {
            IntVector2 p = GetPoint(hp);
            TrackManager.CurrentTrack.Heightmap[p.y][p.x] += delta;
            TerrainManager.UpdateTerrain(p);
        }

        //update terrain's mesh to show the changes
        TerrainManager.PushTerrainChanges();

        //update wireframe shader
        UpdateTerrainShader();

        //also update every tile which is affected
        foreach (var st in _currentSelectedTiles)
        {
            TrackManager.UpdateTerrainAt(st);
        }

        _oldHeight = Input.mousePosition.y * 5 / Screen.height;
    }
Ejemplo n.º 18
0
        public static Bitmap CreateMap(TerrainManager mgr, int scale, int x, int y)
        {
            var img = CreateMap(mgr);
            var map = ImageUtil.ResizeImage(img, img.Width * scale, img.Height * scale);

            return(DrawReticle(map, mgr, x, y, scale));
        }
Ejemplo n.º 19
0
    private void OnGUI()
    {
        scrollPos = EditorGUILayout.BeginScrollView(scrollPos, false, false);

        GUIContent[] layersOptionsMenu = new GUIContent[4];
        layersOptionsMenu[0] = new GUIContent("Ground");
        layersOptionsMenu[1] = new GUIContent("Biome");
        layersOptionsMenu[2] = new GUIContent("Alpha");
        layersOptionsMenu[3] = new GUIContent("Topology");

        EditorGUI.BeginChangeCheck();
        layerIndex = GUILayout.Toolbar(layerIndex, layersOptionsMenu, EditorStyles.toolbarButton);
        if (EditorGUI.EndChangeCheck())
            TerrainManager.ChangeLayer((TerrainManager.LayerType)layerIndex, TerrainTopology.TypeToIndex((int)layers.Topologies));

        if (layerIndex != (int)TerrainManager.CurrentLayerType)
            layerIndex = (int)TerrainManager.CurrentLayerType;

        switch ((TerrainManager.LayerType)layerIndex)
        {
            case TerrainManager.LayerType.Ground:
                Functions.TextureSelect(TerrainManager.CurrentLayerType, ref layers);
                Functions.AreaSelect();
                Functions.LayerTools(TerrainManager.CurrentLayerType, TerrainSplat.TypeToIndex((int)layers.Ground));
                Functions.RotateTools(TerrainManager.CurrentLayerType);
                Functions.RiverTools(TerrainManager.CurrentLayerType, TerrainSplat.TypeToIndex((int)layers.Ground), ref aboveTerrain);
                Functions.SlopeTools(TerrainManager.CurrentLayerType, TerrainSplat.TypeToIndex((int)layers.Ground), ref slopesInfo);
                Functions.HeightTools(TerrainManager.CurrentLayerType, TerrainSplat.TypeToIndex((int)layers.Ground), ref heightsInfo);
                break;
            case TerrainManager.LayerType.Biome:
                Functions.TextureSelect(TerrainManager.CurrentLayerType, ref layers);
                Functions.AreaSelect();
                Functions.LayerTools(TerrainManager.CurrentLayerType, TerrainBiome.TypeToIndex((int)layers.Biome));
                Functions.RotateTools(TerrainManager.CurrentLayerType);
                Functions.RiverTools(TerrainManager.CurrentLayerType, TerrainBiome.TypeToIndex((int)layers.Biome), ref aboveTerrain);
                Functions.SlopeTools(TerrainManager.CurrentLayerType, TerrainBiome.TypeToIndex((int)layers.Biome), ref slopesInfo);
                Functions.HeightTools(TerrainManager.CurrentLayerType, TerrainBiome.TypeToIndex((int)layers.Biome), ref heightsInfo);
                break;
            case TerrainManager.LayerType.Alpha:
                Functions.LayerTools((TerrainManager.LayerType)layerIndex, 0, 1);
                Functions.AreaSelect();
                Functions.RotateTools((TerrainManager.LayerType)layerIndex);
                Functions.RiverTools((TerrainManager.LayerType)layerIndex, 0, ref aboveTerrain, 1);
                Functions.SlopeTools((TerrainManager.LayerType)layerIndex, 0, ref slopesInfo, 1);
                Functions.HeightTools((TerrainManager.LayerType)layerIndex, 0, ref heightsInfo, 1);
                break;
            case TerrainManager.LayerType.Topology:
                Functions.TopologyLayerSelect(ref layers);
                Functions.AreaSelect();
                Functions.LayerTools(TerrainManager.CurrentLayerType, 0, TerrainTopology.TypeToIndex((int)layers.Topologies));
                Functions.RotateTools(TerrainManager.CurrentLayerType, TerrainTopology.TypeToIndex((int)layers.Topologies));
                Functions.TopologyTools();
                Functions.RiverTools(TerrainManager.CurrentLayerType, 0, ref aboveTerrain, 1, TerrainTopology.TypeToIndex((int)layers.Topologies));
                Functions.SlopeTools(TerrainManager.CurrentLayerType, 0, ref slopesInfo, 1, TerrainTopology.TypeToIndex((int)layers.Topologies));
                Functions.HeightTools(TerrainManager.CurrentLayerType, 0, ref heightsInfo, 1, TerrainTopology.TypeToIndex((int)layers.Topologies));
                break;
        }
        EditorGUILayout.EndScrollView();
    }
Ejemplo n.º 20
0
        private void spawnVehicle(Vector3 position, Vector3 rotation, VehicleInfo vehicleInfo)
        {
            NetManager     manager        = Singleton <NetManager> .instance;
            TerrainManager terrainManager = Singleton <TerrainManager> .instance;

            Vector3[] hitPos = new Vector3[2];
            ushort    nodeIndex;
            ushort    segmentIndex;
            bool      rayCastSuccess;

            gameObject.transform.parent      = (Transform)null;
            gameObject.transform.position    = position;
            gameObject.transform.eulerAngles = new Vector3(rotation.x, rotation.y);
            vehicleMesh = vehicleInfo.m_mesh;
            gameObject.AddComponent <MeshFilter>().mesh       = vehicleMesh;
            gameObject.AddComponent <MeshRenderer>().material = vehicleInfo.m_material;
            gameObject.SetActive(true);

            int numLights = vehicleInfo.m_lightPositions.Length > 1 ? 2 : vehicleInfo.m_lightPositions.Length;

            for (int i = 0; i < numLights; i++)
            {
                Vector3    lightPosition = vehicleInfo.m_lightPositions[i];
                GameObject lightObj      = new GameObject();
                Light      light         = lightObj.AddComponent <Light>();
                lightObj.transform.parent        = gameObject.transform;
                lightObj.transform.localPosition = lightPosition;
                light.type      = LightType.Spot;
                light.enabled   = false;
                light.spotAngle = 20f;
                light.range     = 50f;
                light.intensity = 5f;
                light.color     = Color.white;
                mLights.Add(light);
            }

            this.vehicleRigidBody                = gameObject.AddComponent <Rigidbody>();
            this.vehicleRigidBody.isKinematic    = false;
            this.vehicleRigidBody.useGravity     = false;
            this.vehicleRigidBody.drag           = 2f;
            this.vehicleRigidBody.angularDrag    = 2.5f;
            this.vehicleRigidBody.freezeRotation = true;
            this.vehicleCollider = gameObject.AddComponent <BoxCollider>();

            Segment3 ray = new Segment3(position + new Vector3(0f, 1.5f, 0f), position + new Vector3(0f, -100f, 0f));

            rayCastSuccess = manager.RayCast(ray, 0f, ItemClass.Service.Road, ItemClass.Service.PublicTransport, ItemClass.SubService.None, ItemClass.SubService.None, ItemClass.Layer.Default, ItemClass.Layer.None, NetNode.Flags.None, NetSegment.Flags.None, out hitPos[0], out nodeIndex, out segmentIndex);
            rayCastSuccess = rayCastSuccess || manager.RayCast(ray, 0f, ItemClass.Service.Beautification, ItemClass.Service.Water, ItemClass.SubService.None, ItemClass.SubService.None, ItemClass.Layer.Default, ItemClass.Layer.None, NetNode.Flags.None, NetSegment.Flags.None, out hitPos[1], out nodeIndex, out segmentIndex);
            terrainHeight  = terrainManager.SampleDetailHeight(transform.position);
            terrainHeight  = Mathf.Max(terrainHeight, Mathf.Max(hitPos[0].y, hitPos[1].y));

            if (position.y < terrainHeight + 1)
            {
                transform.position = new Vector3(position.x, terrainHeight, position.z);
            }
            prevPosition = transform.position;

            //calculateSlope();
        }
Ejemplo n.º 21
0
    private void Start()
    {
        terrain_manager = terrain_manager_game_object.GetComponent <TerrainManager>();

        friends = GameObject.FindGameObjectsWithTag("Blue");

        AssignID();
    }
Ejemplo n.º 22
0
 public SceneManager(GraphicsDevice graphicsDevice, ContentManager contentManager)
 {
     this.graphicsDevice    = graphicsDevice;
     this.contentManager    = contentManager;
     this.spriteManager     = new SpriteManager(contentManager);
     this.GameObjectManager = new GameObjectManager(contentManager, spriteManager);
     this.TerrainManager    = new TerrainManager(contentManager);
 }
Ejemplo n.º 23
0
    void Awake()
    {
        _trackManager   = GetComponent <TrackManager>();
        _tileManager    = GetComponent <TileManager>();
        _terrainManager = GetComponent <TerrainManager>();

        _tools = new List <ToolGeneral>();
    }
Ejemplo n.º 24
0
 public void Awake()
 {
     manager = GetComponent <TerrainManager>();
     if (playerCamera == null)
     {
         playerCamera = Camera.main;
     }
 }
Ejemplo n.º 25
0
    protected override void Awake()
    {
        base.Awake();

        m_TerrainManager = TerrainManager.Instance;
        m_PlayerArrows   = PlayerArrows.Instance;
        m_HumanPlayer    = BattleRoyaleManager.Instance.GetHumanPlayer();
    }
Ejemplo n.º 26
0
    //! Create A* path.
    public ja2.TerrainTile[] CreatePath(TerrainManager TerrainManager_, ja2.TerrainTile From, ja2.TerrainTile To)
    {
        lastPath = new ja2.AStarPathMap(TerrainManager_, From, To);
        while (lastPath.RunOnce() == ja2.AStarPathMap.State.WAIT)
            ;

        return lastPath.Path();
    }
Ejemplo n.º 27
0
 void CalcHeight()
 {
     height = 0;
     foreach (var kvp in weights)
     {
         height += TerrainManager.GetHeightAt(kvp.Key, x, y) * kvp.Value;
     }
 }
Ejemplo n.º 28
0
    public static void RemoveResourceTile(TerrainManager.Tile tile)
    {
        Vector2           key     = TerrainManager.PosToV2(tile.tile.transform.position);
        SavedResourceTile oldTile = resourceTilesByPos [key];

        data.resourceTiles.Remove(oldTile);
        resourceTilesByPos.Remove(key);
    }
Ejemplo n.º 29
0
 public Bus(int lifeTime, GameObject bus, TerrainManager tm)
 {
     this.lifeTime = lifeTime;
     busTile       = bus;
     this.tm       = tm;
     turnsLeft     = (lifeTime + 1);
     goalSize      = new Vector3(0.1f, 1f, 0.1f);
 }
Ejemplo n.º 30
0
 public Task(string taskName)
 {
     this.TaskName = taskName;
     if (terrainMngInstance == null)
     {
         terrainMngInstance = TerrainManager.instance;
     }
 }
Ejemplo n.º 31
0
    public override void OnSelected()
    {
        SomePrefab.GetComponent <MeshFilter>().mesh = MeshGenerator.GenerateCubeMesh(3, new Vector3(20, 10, 20));
        TerrainManager.ApplyTerrainToMesh(SomePrefab.GetComponent <MeshFilter>().mesh, _gridPosition, 0, new IntVector2(1, 1), false);
        SomePrefab.GetComponent <MeshRenderer>().materials = new[] { _mat };

        SomePrefab.GetComponent <MeshRenderer>().enabled = true;
    }
Ejemplo n.º 32
0
        static bool ModifyMask(ProfileSection[] profile, Vector3 startPos, Vector3 endPos, Vector3 startLeftPos, Vector3 startRightPos, Vector3 endLeftPos, Vector3 endRightPos, float halfWidth, bool invert, int index, ref TerrainModify.Surface surface, ref TerrainModify.Heights heights, ref TerrainModify.Edges edges, ref float leftT, ref float rightT, ref float leftStartY, ref float rightStartY, ref float leftEndY, ref float rightEndY, ref bool __result)
        {
            if (index >= profile.Length)
            {
                __result = false;
                return(false);
            }

            TerrainManager terrainManager = Singleton <TerrainManager> .instance;
            ProfileSection section        = profile[index];

            if (invert)
            {
                section = section.Inverse();
            }

            if (section.Heights.HasValue)
            {
                heights = section.Heights.Value;
            }
            if (section.Surface.HasValue)
            {
                surface = section.Surface.Value;
            }
            if (section.EdgeFlags.HasValue)
            {
                edges = section.EdgeFlags.Value;
            }
            leftT       = section.PosRel[0] + section.PosAbs[0] / (2f * halfWidth);
            rightT      = section.PosRel[1] + section.PosAbs[1] / (2f * halfWidth);
            leftStartY  = section.HeightOffset[0];
            leftEndY    = section.HeightOffset[1];
            rightStartY = section.HeightOffset[2];
            rightEndY   = section.HeightOffset[3];
            if (section.HeightTerrain[0] != 0)
            {
                Vector3 sectionStartLeftPos = Vector3.Lerp(startLeftPos, startRightPos, leftT);
                leftStartY += section.HeightTerrain[0] * (terrainManager.SampleOriginalRawHeightSmooth(sectionStartLeftPos) - startPos.y);
            }
            if (section.HeightTerrain[1] != 0)
            {
                Vector3 sectionEndLeftPos = Vector3.Lerp(endLeftPos, endRightPos, leftT);
                leftEndY += section.HeightTerrain[0] * (terrainManager.SampleOriginalRawHeightSmooth(sectionEndLeftPos) - endPos.y);
            }
            if (section.HeightTerrain[2] != 0)
            {
                Vector3 sectionStartRightPos = Vector3.Lerp(startLeftPos, startRightPos, rightT);
                rightStartY += section.HeightTerrain[0] * (terrainManager.SampleOriginalRawHeightSmooth(sectionStartRightPos) - startPos.y);
            }
            if (section.HeightTerrain[3] != 0)
            {
                Vector3 sectionEndRightPos = Vector3.Lerp(endLeftPos, endRightPos, rightT);
                rightEndY += section.HeightTerrain[0] * (terrainManager.SampleOriginalRawHeightSmooth(sectionEndRightPos) - endPos.y);
            }

            __result = true;
            return(false);
        }
Ejemplo n.º 33
0
    // Use this for initialization
    void Start()
    {
        terrain_manager = terrain_manager_game_object.GetComponent <TerrainManager>();

        start_time = Time.time;

        race_car.transform.position = terrain_manager.myInfo.start_pos + 2f * Vector3.up;
        race_car.transform.rotation = Quaternion.identity;
    }
        public static void UpdateData(TerrainManager _this, SimulationManager.UpdateMode mode)
        {
            DataExtension.instance.OnUpdateData();

            // Call original method
            UpdateDataRedirector.Revert();
            _this.UpdateData(mode);
            UpdateDataRedirector.Apply();
        }
Ejemplo n.º 35
0
    // Use this for initialization
    void Start()
    {
        console = GameObject.Find("console");

        terrainManager = gameObject.AddComponent("TerrainManager") as TerrainManager;
        obstacleControll = gameObject.AddComponent("ObstacleControll") as ObstacleControll;

        // GameObject person =Instantiate (Resources.Load("objects/soccerMan")) as GameObject;
        //SkinnedMeshRenderer render = person.GetComponentInChildren<SkinnedMeshRenderer>();
        //person.transform.position = new Vector3(0, render.bounds.extents.y*10, 0);
    }
Ejemplo n.º 36
0
	private static bool IsInstance () {
		if (instance == null) {
			instance = FindObjectOfType (typeof (TerrainManager)) as TerrainManager;
			
			if (instance == null) {
				Debug.LogWarning ("Can't seem to find any Gameobject that has TerrainManager class");
				return false;
			}
		}
		
		return true;
	}
Ejemplo n.º 37
0
	/// <summary>
	/// Initialize singleton
	/// </summary>
	void Awake()
	{
		if (use != null) {
			Destroy(use.gameObject);
		}
		use = this;
		
		MessengerAM.Listen(MessengerAM.listenTypeInput, this);
		MessengerAM.Listen("www", this);
		MessengerAM.Listen("world", this);
		
		m_objectGrouper = new GameObject("TerrainObjects");
		
		// initialize the terrain
		InitializeTerrain();
	}
Ejemplo n.º 38
0
    void Awake()
    {
        terrainManager = GameObject.Find("Map").GetComponent<TerrainManager>();
        // Create A* path manager and GO
        pathManager = utils.PrefabManager.Create("AStartPathManager").GetComponent<AStarPathManager>();
        pathManager.transform.parent = transform;

        soldiersPaths = new Dictionary<SoldierController, SoldierPathManager>();
        // Instantiate cursor if not found
        GameObject cursor_go;
        if ((cursor_go = GameObject.Find("Cursor")) == null)
        {
            var prefab_class = Resources.Load("Prefabs/Cursor", typeof(GameObject));
            cursor_go = (GameObject)Instantiate(prefab_class);
            cursor_go.name = prefab_class.name;
            // Save it
            cursor = cursor_go.GetComponent<GameCursor>();
        }
        // Instantiate hover
        if ((hover = GameObject.Find("Hover")) == null)
        {
            var prefab_class = Resources.Load("Prefabs/Hover", typeof(GameObject));
            hover = (GameObject)Instantiate(prefab_class);
            hover.name = prefab_class.name;
        }
        // Create path visulizer child GO and get main component
        var path_visualizer_go = utils.PrefabManager.Create("PathVisualizer");
        path_visualizer_go.transform.parent = transform;
        pathVisualizer = path_visualizer_go.GetComponent<PathVisualizer>();

        charDefManager = new ja2.CharacterDefinitionManager("Data");
        clothManager = new ja2.ClothManager("Data");
        charEntityManager = new ja2.CharacterEntityManager(charDefManager, clothManager);
    }
Ejemplo n.º 39
0
    void Awake()
    {
        processor = FindObjectOfType<AudioProcessor>();
        processor.addAudioCallback(this);

        enemiesSpawner = EnemyManager.Instance;
        platformSpawn = TerrainManager.Instance;

        player = LoadCharacter.Instance.GetCharacter().transform;

        _lastShoot = Time.time;
    }
Ejemplo n.º 40
0
 void Awake()
 {
     terrainManager = GameObject.Find("Map").GetComponent<TerrainManager>();
     meshFilter = GetComponent<MeshFilter>();
 }
Ejemplo n.º 41
0
        /// <summary>
        /// Initializes the engine. Should be called in <c>Game.LoadContent()</c>.
        /// </summary>
        public void Initialize()
        {
            if (!this.EngineInitialized)
            {
                this.Cameras = new Collection<Camera>();
                this.ClearColor = Color.SkyBlue;
                this.Effects = new Collection<Effect>();
                this.Fonts = new Collection<SpriteFont>();
                this.Players = new PlayerCollection();
                this.CurrentCamera = new ChaseCamera(null);
                this.Terrain = new TerrainManager();

                if (this.GraphicsDevice != null)
                {
                    this.SpriteBatch = new SpriteBatch(this.GraphicsDevice);
                }

                this.PickedObjects = new ReadOnlyCollection<GameObjectBase>(new Collection<GameObjectBase>());
                this.objectPicking = new ObjectPicking();
                this.frameCounter = new FrameCounter();
                this.Compass = new Compass();

                this.EngineInitialized = true;
            }
        }
Ejemplo n.º 42
0
	void Awake () {
		instance = this;
	}
Ejemplo n.º 43
0
 public System.Collections.IEnumerator CreatePathDebug_CoRo(TerrainManager TerrainManager_, ja2.TerrainTile From, ja2.TerrainTile To)
 {
     lastPath = new ja2.AStarPathMap(TerrainManager_, From, To);
     ja2.AStarPathMap.State state;
     do
     {
         yield return new WaitForSeconds(time);
         state = lastPath.RunOnce();
     } while (state == ja2.AStarPathMap.State.WAIT);
 }
Ejemplo n.º 44
0
        private void CreateTerrain()
        {
            mTMgr = new MET.TerrainManager(OgreEngine.mMgr, "MET");

            mTMgr.SetLodErrorMargin(2, OgreEngine.mWin.Height);
            mTMgr.SetUseLodMorphing(true, 0.2f, "morphFactor");

            mTInfo = new MET.TerrainInfo();
            Mogre.Image image = new Mogre.Image();

            image.Load("heightmap.png", ResourceGroupManager.DEFAULT_RESOURCE_GROUP_NAME);
            MET.TerrainInfo.LoadHeightmapFromImage(mTInfo, image);
            //mTInfo.Extents = new Mogre.AxisAlignedBox(0, 0, 0, land.SizeX + stepWidth, land.SizeZ, land.SizeY + stepHeight);
            mTInfo.Extents = new Mogre.AxisAlignedBox(Vector3.ZERO, Size);

            //lightmap
            Mogre.Image lmImage = new Mogre.Image();
            MET.TerrainInfo.CreateTerraingLightmap(mTInfo, lmImage, Constants.Land.LightmapSize, Constants.Land.LightmapSize, new Vector3(-1, -1, -1), new ColourValue(1, 1, 1), new ColourValue(0.2f, 0.2f, 0.2f), true);
            //lmImage.Save("lightmapa" + land.Id + ".png");
            TexturePtr lightmapTex = TextureManager.Singleton.CreateManual(
                "ETLightmap",
                ResourceGroupManager.DEFAULT_RESOURCE_GROUP_NAME,
                Mogre.TextureType.TEX_TYPE_2D,
                Constants.Land.LightmapSize,
                Constants.Land.LightmapSize,
                1,
                Mogre.PixelFormat.PF_BYTE_RGB);

            TexturePtr tex = TextureManager.Singleton.GetByName("ETLightmap");
            tex.GetBuffer(0, 0).BlitFromMemory(lmImage.GetPixelBox(0, 0));

            mTMgr.CreateTerrain(mTInfo);
            mTInfo.Dispose();
            mTInfo = mTMgr.TerrainInfo;

            image = new Image();
            image.Load("textureMap0.png", ResourceGroupManager.DEFAULT_RESOURCE_GROUP_NAME);
            TextureSize = image.Width;
            mSMgr = new MET.SplattingManager("ETSplatting", ResourceGroupManager.DEFAULT_RESOURCE_GROUP_NAME, image.Width, image.Width, 3);
            mSMgr.NumTextures = 6;

            mSMgr.LoadMapFromImage(0, image);
            image = new Image();
            image.Load("textureMap1.png", ResourceGroupManager.DEFAULT_RESOURCE_GROUP_NAME);
            mSMgr.LoadMapFromImage(1, image);

            mTMgr.Material = MaterialManager.Singleton.GetByName("ETTerrainMaterial");

            // lightmapa
            Pass pass = mTMgr.Material.GetTechnique(0).CreatePass();
            pass.LightingEnabled = false;
            pass.SetSceneBlending(SceneBlendType.SBT_MODULATE);
            pass.SetVertexProgram("ET/Programs/VSLodMorph2");
            pass.SetFragmentProgram("ET/Programs/PSLighting");
            pass.CreateTextureUnitState("ETLightmap");

            pass = mTMgr.Material.GetTechnique(1).CreatePass();
            pass.LightingEnabled = false;
            pass.SetSceneBlending(SceneBlendType.SBT_MODULATE);
            pass.SetVertexProgram("ET/Programs/VSLodMorph2");
            pass.SetFragmentProgram("ET/Programs/PSLighting");
            pass.CreateTextureUnitState("ETLightmap");

            //base texture for non shader graphics
            lmImage = new Mogre.Image();
            //TODO: replace by real bic texture
            lmImage.Load("baseTexture.jpg", ResourceGroupManager.DEFAULT_RESOURCE_GROUP_NAME);
            //lmImage.Save("lightmapa" + land.Id + ".png");
            lightmapTex = TextureManager.Singleton.CreateManual(
                "ETBasemap",
                ResourceGroupManager.DEFAULT_RESOURCE_GROUP_NAME,
                Mogre.TextureType.TEX_TYPE_2D,
                Constants.Land.LightmapSize,
                Constants.Land.LightmapSize,
                1,
                Mogre.PixelFormat.PF_BYTE_RGB);

            tex = TextureManager.Singleton.GetByName("ETBasemap");
            tex.GetBuffer(0, 0).BlitFromMemory(lmImage.GetPixelBox(0, 0));

            Technique tech = mTMgr.Material.CreateTechnique();
            pass = tech.CreatePass();
            pass.CreateTextureUnitState("ETBasemap");
        }
Ejemplo n.º 45
0
    public void Setup()
    {
        if (Rules != null)
        {
            Settings s = new Settings();
            s.Rules = Rules;
            s.PrefabRules = PrefabRules;

            s.MainMaterial = MainMaterial;
            s.MainMaterialXTiling = MainMaterialXTiling;
            s.MainMaterialYTiling = MainMaterialYTiling;
            s.MainMaterialRotation = MainMaterialRotation;

            s.TopMaterial = TopMaterial;
            s.TopMaterialXTiling = TopMaterialXTiling;
            s.TopMaterialYTiling = TopMaterialYTiling;
            s.TopMaterialRotation = TopMaterialRotation;
            s.DrawTopMeshCollider = DrawTopMeshCollider;
            s.DrawTopMeshRenderer = DrawTopMeshRenderer;

            s.DetailMaterial = DetailMaterial;
            s.DetailMaterialXTiling = DetailMaterialXTiling;
            s.DetailMaterialYTiling = DetailMaterialYTiling;
            s.DetailMaterialRotation = DetailMaterialRotation;
            s.DrawDetailMeshRenderer = DrawDetailMeshRenderer;

            s.MainPlaneHeight = MainPlaneHeight;
            s.TopPlaneHeight = TopPlaneHeight;
            s.DetailPlaneHeight = DetailPlaneHeight;

            s.CornerMeshWidth = CornerMeshWidth;

            s.OriginalStartPoint = this.transform.position;
            s.DetailPlaneOffset = new Vector3(0,.1f,-.2f);

            s.MainPlaneFollowTerrainCurve = MainPlaneFollowTerrainCurve;
            s.DetailPlaneFollowTerrainCurve = DetailPlaneFollowTerrainCurve;

            s.ParentGameObjectName = this.name;
            s.terrainDisplayer = this;

            TerrainManager = new TerrainManager(s);
            PrefabManager = new PrefabManager(s);

            Cleanup();

        }
    }
Ejemplo n.º 46
0
 void Start()
 {
     TMANAGER = gameObject.GetComponent<TerrainManager>();
 }
Ejemplo n.º 47
0
	void Start() {
		terrainManager = GameObject.Find("TerrainManager").GetComponent<TerrainManager>();
	}