Наследование: ScriptableWizard
Пример #1
0
    void Awake()
    {
        if (mInstance == null)
        {
            mInstance = this;

            // Work out the width of each column
            mColumnWidth = (GameLogic.ScreenHeight * GameplayCamera.aspect * 0.8f) / (int)Column.NumColumns;

            // Create the enemies, initialise the active and available lists, put all enemies in the available list
            mActive   = new List <GameObject>();
            mInactive = new List <GameObject>();
            mPool     = new GameObject[EnemyPoolSize];
            for (int count = 0; count < mPool.Length; count++)
            {
                GameObject enemy = new GameObject("Enemy_Pool_ID_" + (count + 1));
                CreateMesh m     = enemy.AddComponent <CreateMesh>();
                m.Material = EnemyMaterial;
                enemy.transform.localScale    = new Vector3(EnemyScale, EnemyScale, EnemyScale);
                enemy.transform.localRotation = Quaternion.AngleAxis(180.0f, Vector3.forward);
                enemy.transform.parent        = transform;
                mPool[count] = enemy;
                mInactive.Add(enemy);
                enemy.SetActive(false);
            }
        }
        else
        {
            Debug.LogError("Only one EnemyFactory allowed - destorying duplicate");
            Destroy(this.gameObject);
        }
    }
Пример #2
0
    /// <summary>
    /// Setup the specified length, height, level array, next level and start on the y axis (y axis is different for exterior CA terrain levels) to begin level creation from 3D arrays.
    /// </summary>
    /// <param name="l">The length</param>
    /// <param name="h">The height.</param>
    /// <param name="lev">The level array.</param>
    /// <param name="nl">The next level to be loaded after this one.</param>
    /// <param name="sy">Where to start along the y axis within the 3D array.</param>
    public void setup(int l, int h, int[,,] lev, int nl, int sy)
    {
        int length = l;
        int height = h;

        nextLevel = nl;
        int startY = sy;

        myMesh = new CreateMesh(length);
        for (int x = 0; x < length; x++)
        {
            for (int z = 0; z < length; z++)
            {
                for (int y = startY; y < height; y++)
                {
                    if (lev[x, z, y] == 1)
                    {
                        //place cube in level based on array coordinates, multiply by 1.5 as cubes are size 1.5 not 1
                        Transform cube = Instantiate(cubePrefab, new Vector3(x * 1.5f, (y - startY) * 1.5f, z * 1.5f), Quaternion.identity) as Transform;
                        int       m    = myMesh.getMesh(x, z, y);                                               //get mesh number based on position of cube
                        //make cube child object of tagged mesh object that corresponds to its position by accessing meshTags string array
                        cube.transform.parent = GameObject.FindGameObjectWithTag(myMesh.meshTags[m]).transform; //mesh objects already exist in scene and are tagged from "mesh1" to "mesh64"
                    }
                }
            }
        }
        Instantiate(player);  //place player in scene
        audio.Play();         //play level's ambient background sound
    }
Пример #3
0
    public Bullet (int count, Transform ParentTransform) {
        bullet = new GameObject("Bullet_Pool_ID_" + (count + 1));
        mesh = bullet.AddComponent<CreateMesh>();
        bullet.transform.localScale = new Vector3(Weapon.BulletScale, Weapon.BulletScale, Weapon.BulletScale );
        bullet.transform.parent = ParentTransform;
        this.ParentTransform = ParentTransform;
	    bullet.SetActive( false );
	}
Пример #4
0
    public Enemy(Material material, int count)
    {
        enemy = new GameObject("Enemy_PoolID" + (count + 1));
        CreateMesh m = enemy.AddComponent <CreateMesh>();

        m.Material = material;
        enemy.transform.localRotation = Quaternion.AngleAxis(180.0f, Vector3.forward);
        enemy.SetActive(false);
    }
Пример #5
0
    // Start is called before the first frame update
    void Start()
    {
        inputColomns = inputColomns.GetComponent <InputField>();
        inputRows    = inputRows.GetComponent <InputField>();


        GameObject MeshController = GameObject.Find("MeshController");

        CreateMeshScript = MeshController.GetComponent <CreateMesh>();
    }
Пример #6
0
 private void Awake()
 {
     if (_instance != null && _instance != this)
     {
         Destroy(this.gameObject);
     }
     else
     {
         _instance = this;
     }
 }
    void CreateLevelpath(int pathNum, GameObject parent)
    {
        GameObject Levelpath = new GameObject("Path");

        Levelpath.transform.parent = parent.transform;
        CreateMesh m = Levelpath.AddComponent <CreateMesh>();

        m.Material = levelMaterial;
        Levelpath.transform.position = parent.transform.position + new Vector3((-pathNum * levelDistance / 5.0f), 0, 0);
        float localScale = 0.4f;

        Levelpath.transform.localScale = new Vector3(localScale, localScale, 1);
    }
Пример #8
0
    public Boss(Camera camera, Material material)
    {
        TheBoss = new GameObject("Big Boss");
        CreateMesh m = TheBoss.AddComponent <CreateMesh>();

        m.Material   = material;
        health       = DifficultyCurve.BossStrength;
        activeWidth  = GameLogic.ScreenHeight * camera.aspect * 0.4f;
        NextPosition = new Vector3(0f, GameLogic.ScreenHeight * 0.5f, 0f);
        TheBoss.transform.position      = new Vector3(0f, GameLogic.ScreenHeight * 0.6f, 0f);
        TheBoss.transform.localScale    = new Vector3(Size, Size, Size);
        TheBoss.transform.localRotation = Quaternion.AngleAxis(180.0f, Vector3.forward);
    }
Пример #9
0
    public void OnEnable()
    {
        _cm = GetComponent<CreateMesh>();

        var json = Resources.Load("level1", typeof(TextAsset)).ToString();
        _level = Level1.LoadLevel((Hashtable)JSON.JsonDecode(json), _cm.NumTilesX, _cm.NumTilesY);

        _cm.CreatePlane(_level.Width, _level.Height);

        for (var y = 0; y < _level.Height; y++) {
            for (var x = 0; x < _level.Width; x++) {
                _cm.UpdateGrid(new Vector2(x, y), _level.Grid[x, y]);
            }
        }
    }
Пример #10
0
    /// <summary>
    /// Setup the specified length and next level. This overloaded method is used by the Perlin Noise terrain as it uses a specific 2D array.
    /// </summary>
    /// <param name="l">The length</param>
    /// <param name="nl">The next level to be loaded after this one.</param>
    public void setup(int l, int nl)
    {
        int length = l;

        nextLevel = nl;
        myMesh    = new CreateMesh(length);
        for (int x = 0; x < length; x++)
        {
            for (int z = 0; z < length; z++)
            {
                Transform cube = Instantiate(cubePrefab, new Vector3(x * 1.5f, StaticObjects.pnTerrain[x, z] * 1.5f, z * 1.5f), Quaternion.identity) as Transform;
                int       m    = myMesh.getMesh(x, z);       //uses overloaded getMesh function for 2D arrays
                cube.transform.parent = GameObject.FindGameObjectWithTag(myMesh.meshTags[m]).transform;
            }
        }
        Instantiate(player);
        audio.Play();
    }
Пример #11
0
 public void CreateGround()
 {
     if (New_LineManager.Instance.IsBiHe())
     {
         //形成面至少三点
         if (m_enterPoints.Count > 2)
         {
             //  m_enterPoints.RemoveAt(m_enterPoints.Count - 1);
             cad.SetActive(false);
             //调用形成多变形方法
             CreateMesh tCreatMesh = new CreateMesh();
             // tCreatMesh.DoCreatPloygonMesh(m_enterPoints.ToArray(), material);//DemoMesh
             tCreatMesh.DemoMesh(m_enterPoints.ToArray(), material);//DemoMesh
             //每次绘制完清空手动获取的点列表
             m_enterPoints.Clear();
             camCon.enabled = true;
         }
         m_enterPoints.Clear();
     }
 }
Пример #12
0
    void Start()
    {
        switch (UserData.CurrentLevel) // Different star color based on current level
        {
        case 0:
            SceneryMaterial.color = Color.white;
            break;

        case 1:
            SceneryMaterial.color = Color.cyan;
            break;

        case 2:
            SceneryMaterial.color = new Color(114.0f / 255.0f, 189.0f / 255.0f, 100.0f / 255.0f);
            break;

        case 3:
            SceneryMaterial.color = new Color(255.0f / 255.0f, 145.0f / 255.0f, 26.0f / 255.0f);
            break;

        case 4:
            SceneryMaterial.color = new Color(255.0f / 255.0f, 26.0f / 255.0f, 230.0f / 255.0f);
            break;
        }
        // Create the scenery and position
        mPool = new GameObject[SceneryPoolSize];
        for (int count = 0; count < SceneryPoolSize; count++)
        {
            GameObject sceneryItem = new GameObject("Scenery_PoolID" + (count + 1));
            CreateMesh m           = sceneryItem.AddComponent <CreateMesh>();
            m.Material = SceneryMaterial;
            float x     = Random.Range(-GameLogic.ScreenBounds, GameLogic.ScreenBounds);
            float y     = Random.Range(GameLogic.ScreenHeight * -0.5f, GameLogic.ScreenHeight * 0.5f);
            float scale = Random.Range(SceneryMinScale, SceneryMaxScale);
            sceneryItem.transform.position      = new Vector3(x, y, 0.0f);
            sceneryItem.transform.localScale    = new Vector3(scale, scale, scale);
            sceneryItem.transform.localRotation = Quaternion.AngleAxis(180.0f, Vector3.forward);
            sceneryItem.transform.parent        = transform;
            mPool[count] = sceneryItem;
        }
    }
    void CreateLevel(int levelNum, Vector3 position)
    {
        GameObject Level = new GameObject("Level" + levelNum);

        Level.transform.parent = transform;
        CreateMesh m = Level.AddComponent <CreateMesh>();

        if (DifficultyCurve.Levels[levelNum].Length == 1) //If this is a boss level, use the boss material
        {
            m.Material = bossMaterial;
        }
        else
        {
            m.Material = levelMaterial;
        }
        Level.transform.position   = position;
        Level.transform.localScale = new Vector3(5, 5, 5);

        if (levelNum > 0) //For each level after the first one - create a "path" of small discs
        {
            for (int i = 0; i <= levelDistance / 5.0f; i++)
            {
                CreateLevelpath(i, Level);
            }
        }

        //Write the best score below the level
        GameObject pbText = new GameObject("PreviousBest" + levelNum);

        pbText.transform.parent = Level.transform;
        TextMesh textMesh = pbText.AddComponent <TextMesh>();

        textMesh.font = pbFont;
        var meshRenderer = pbText.GetComponent <MeshRenderer>();

        meshRenderer.material       = pbMat;
        textMesh.text               = UserData.LevelMaxPoints[levelNum].ToString();
        pbText.transform.localScale = new Vector3(0.1f, 0.1f, 1);
        pbText.transform.position   = Level.transform.position + new Vector3(-0.5f - (UserData.LevelMaxPoints[levelNum].ToString().Length * 0.85f), -5, 0);
    }
Пример #14
0
    void Start()
    {
        // Create the scenery and position
        mPool = new GameObject[SceneryPoolSize];
        for (int count = 0; count < SceneryPoolSize; count++)
        {
            GameObject sceneryItem = new GameObject("Scenery_Pool_ID_" + (count + 1));
            CreateMesh m           = sceneryItem.AddComponent <CreateMesh>();
            m.Material = SceneryMaterial;
            float x     = Random.Range(-GameLogic.ScreenBounds, GameLogic.ScreenBounds);
            float y     = Random.Range(GameLogic.ScreenHeight * -0.5f, GameLogic.ScreenHeight * 0.5f);
            float scale = Random.Range(SceneryMinScale, SceneryMaxScale);

            /* Put the scenery at 0.1 depth, because there seems to be no other reliable way to make sure
             * it doesn't get rendered in front of the actors.
             */
            sceneryItem.transform.position      = new Vector3(x, y, 0.1f);
            sceneryItem.transform.localScale    = new Vector3(scale, scale, scale);
            sceneryItem.transform.localRotation = Quaternion.AngleAxis(180.0f, Vector3.forward);
            sceneryItem.transform.parent        = transform;
            mPool[count] = sceneryItem;
        }
    }
Пример #15
0
    // Update is called once per frame
    void Update()
    {
        //左键取点
        if (Input.GetMouseButtonDown(0))
        {
            //屏幕位置转射线
            Ray tRay = Camera.main.ScreenPointToRay(Input.mousePosition);
            //射线返回点信息
            RaycastHit tHit;
            //发射射线
            if (Physics.Raycast(tRay, out tHit))
            {
                //如果打在地面上,则将点存储起来
                if (tHit.transform.tag == "Ground")
                {
                    //这里为了形成的面不与原先底板重合,提升了一个高度
                    m_enterPoints.Add(tHit.point + new Vector3(0, 0.01f, 0));
                }
            }
        }

        //右键形成面
        if (Input.GetMouseButtonDown(1))
        {
            //形成面至少三点
            if (m_enterPoints.Count > 2)
            {
                //调用形成多变形方法
                CreateMesh tCreatMesh = new CreateMesh();
                tCreatMesh.DoCreatPloygonMesh(m_enterPoints.ToArray());

                //每次绘制完清空手动获取的点列表
                m_enterPoints.Clear();
            }
        }
    }
    void Start()
    {
        float ScreenBounds = OverworldLevelRenderer.LevelDistance * (DifficultyCurve.Levels.Count + 2);

        //Increase pool size as the overworld corresponds to more than a single screensize
        int actualSceneryPoolSize = (int)((float)SceneryPoolSize / OverworldLogic.ScreenBounds * ScreenBounds);

        // Create the scenery and position
        mPool = new GameObject[actualSceneryPoolSize];
        for (int count = 0; count < actualSceneryPoolSize; count++)
        {
            GameObject sceneryItem = new GameObject("Scenery_PoolID" + (count + 1));
            CreateMesh m           = sceneryItem.AddComponent <CreateMesh>();
            m.Material = SceneryMaterial;
            float x     = Random.Range(-ScreenBounds, ScreenBounds);
            float y     = Random.Range(OverworldLogic.ScreenHeight * -0.5f, OverworldLogic.ScreenHeight * 0.5f);
            float scale = Random.Range(SceneryMinScale, SceneryMaxScale);
            sceneryItem.transform.position      = new Vector3(x, y, 0.0f);
            sceneryItem.transform.localScale    = new Vector3(scale, scale, scale);
            sceneryItem.transform.localRotation = Quaternion.AngleAxis(180.0f, Vector3.forward);
            sceneryItem.transform.parent        = transform;
            mPool[count] = sceneryItem;
        }
    }
Пример #17
0
 public void initializtion(int id, CreateMesh _createMesh)
 {
     Id         = id;
     weights    = 1f;
     createMesh = _createMesh;
 }
Пример #18
0
 public static void Create() => CreateMesh.Create(@"Mino_L", vertices, triangles, uv);