Inheritance: MonoBehaviour
示例#1
0
 // Use this for initialization
 void Start()
 {
     isShooting = false;
     //characterName = "Amor";
     homeHex            = positon.gameObject.GetComponent <HexagonBehaviour>();
     homeHex.inhabitant = this.gameObject;
 }
示例#2
0
    public IEnumerator checkBlackTrapezoidsNotDestroying()
    {
        UnityEngine.SceneManagement.SceneManager.LoadScene("Game");

        yield return(new WaitForSeconds(0.1f));

        GameObject spawner = GameObject.Find("SpawningObject");

        GameObject.Destroy(spawner);
        GameObject       blackHexagon = GameObject.FindGameObjectWithTag("Black Hexagon");
        HexagonBehaviour preventInput = blackHexagon.GetComponent <HexagonBehaviour> ();

        preventInput.enabled = false;

        GameObject canvas = GameObject.Find("Canvas");

        yield return(new WaitForSeconds(1f));

        Spawner.angle = 60f;
        GameObject firstBlack = GameObject.Instantiate((GameObject)Resources.Load("Prefabs/BlackTrapezoid"), canvas.transform);

        yield return(new WaitForSeconds(1f));

        GameObject secondBlack = GameObject.Instantiate((GameObject)Resources.Load("Prefabs/BlackTrapezoid"), canvas.transform);

        yield return(new WaitForSeconds(1f));

        GameObject thirdBlack = GameObject.Instantiate((GameObject)Resources.Load("Prefabs/BlackTrapezoid"), canvas.transform);

        yield return(new WaitForSeconds(4f));


        Assert.IsTrue(GameObject.Find("BlackTrapezoid(Clone)") != null);
    }
示例#3
0
    // Initialize Hexagon Dungeon
    private HexagonBehaviour createHexagonDungeon()
    {
        GameObject       hex_obj     = new GameObject("HexagonDungeon");
        HexagonBehaviour new_dungeon = hex_obj.AddComponent <HexagonBehaviour>();

        return(new_dungeon);
    }
示例#4
0
    public IEnumerator checkThreeConnection()
    {
        UnityEngine.SceneManagement.SceneManager.LoadScene("Game");

        yield return(new WaitForSeconds(0.1f));

        GameObject spawner = GameObject.Find("SpawningObject");

        GameObject.Destroy(spawner);
        GameObject       blackHexagon = GameObject.FindGameObjectWithTag("Black Hexagon");
        HexagonBehaviour preventInput = blackHexagon.GetComponent <HexagonBehaviour> ();

        preventInput.enabled = false;

        GameObject canvas = GameObject.Find("Canvas");

        Spawner.angle = 60f;
        GameObject firstRed = GameObject.Instantiate((GameObject)Resources.Load("Prefabs/RedTrapezoid"), canvas.transform);

        yield return(new WaitForSeconds(0.5f));

        Spawner.angle = 120f;
        GameObject secondRed = GameObject.Instantiate((GameObject)Resources.Load("Prefabs/RedTrapezoid"), canvas.transform);

        yield return(new WaitForSeconds(0.5f));

        Spawner.angle = 180f;
        GameObject thirdRed = GameObject.Instantiate((GameObject)Resources.Load("Prefabs/RedTrapezoid"), canvas.transform);

        yield return(new WaitForSeconds(4));

        //Assures all gameObjects loaded into the scene are destroyed.
        Assert.IsTrue(GameObject.FindGameObjectsWithTag("RedTrapezoid(Clone)").Length == 0);
    }
示例#5
0
    // Use this for initialization
    void Start()
    {
        isSlowed = false;

        homeHex                = positon.gameObject.GetComponent <HexagonBehaviour>();
        homeHex.inhabitant     = this.gameObject;
        homeHex.inhabitantType = 2;
    }
示例#6
0
    public IEnumerator checkGameOverCondition()
    {
        UnityEngine.SceneManagement.SceneManager.LoadScene("Game");

        yield return(new WaitForSeconds(0.1f));

        GameObject spawner = GameObject.Find("SpawningObject");

        GameObject.Destroy(spawner);
        GameObject       blackHexagon = GameObject.FindGameObjectWithTag("Black Hexagon");
        HexagonBehaviour preventInput = blackHexagon.GetComponent <HexagonBehaviour> ();

        preventInput.enabled = false;

        GameObject canvas = GameObject.Find("Canvas");

        yield return(new WaitForSeconds(1f));

        Spawner.angle = 60f;
        GameObject firstRed = GameObject.Instantiate((GameObject)Resources.Load("Prefabs/RedTrapezoid"), canvas.transform);

        yield return(new WaitForSeconds(1f));

        GameObject firstBlue = GameObject.Instantiate((GameObject)Resources.Load("Prefabs/BlueTrapezoid"), canvas.transform);

        yield return(new WaitForSeconds(1f));

        GameObject secondBlue = GameObject.Instantiate((GameObject)Resources.Load("Prefabs/BlueTrapezoid"), canvas.transform);

        yield return(new WaitForSeconds(1f));

        GameObject droppingYellow = GameObject.Instantiate((GameObject)Resources.Load("Prefabs/YellowTrapezoid"), canvas.transform);

        yield return(new WaitForSeconds(1f));

        GameObject secondRed = GameObject.Instantiate((GameObject)Resources.Load("Prefabs/RedTrapezoid"), canvas.transform);

        yield return(new WaitForSeconds(1f));

        GameObject thirdBlue = GameObject.Instantiate((GameObject)Resources.Load("Prefabs/BlueTrapezoid"), canvas.transform);

        yield return(new WaitForSeconds(1f));

        GameObject fourthBlue = GameObject.Instantiate((GameObject)Resources.Load("Prefabs/BlueTrapezoid"), canvas.transform);

        yield return(new WaitForSeconds(1f));

        GameObject gameOverBlock = GameObject.Instantiate((GameObject)Resources.Load("Prefabs/YellowTrapezoid"), canvas.transform);


        yield return(new WaitForSeconds(3f));

        GameObject checkNoBlackHexagon = GameObject.FindGameObjectWithTag("Black Hexagon");

        yield return(new WaitForSeconds(2f));

        Assert.IsNull(checkNoBlackHexagon);
    }
示例#7
0
    public void SetTiles(int operationNumber)
    {
        Hexagon[] tiles = GetComponent <Tiles>().GetAllTiles();

        for (int i = 0; i < tiles.Length; i++)
        {
            switch (operationNumber)
            {
            case CRACKABLES:
            {
                HexagonBehaviour hexagon = tiles[i].GetComponent <HexagonBehaviour>();
                hexagon.SetCrackedTileBreaksInTime(crackedTileBreaksInSeconds);
                //   hexagon.SetFallDepth(fallDepth);
                break;
            }

            case VELOCITIY:
            {
                HexagonSpecial hexagon = tiles[i].GetComponent <HexagonSpecial>();
                if (hexagon)
                {
                    hexagon.SetVelocity(velocity);
                }
                break;
            }

            case LOSING:
            {
                Hexagon hexagon = tiles[i];
                if (hexagon.IsStandardTile())
                {
                    hexagon.SetIsSpecialTile(3);
                }
                break;
            }

            case REMOVE_LOSING:
            {
                Hexagon hexagon = tiles[i];
                if (hexagon.GetSpecialNumber() == 3)
                {
                    hexagon.SetIsSpecialTile(-1);
                }
                break;
            }

            case JUMP_PADS:
            {
                HexagonSpecial hexagon = tiles[i].GetComponent <HexagonSpecial>();
                if (hexagon)
                {
                    hexagon.SetJumpDirection(jumpDirection);
                }
                break;
            }
            }
        }
    }
示例#8
0
    public IEnumerator checkRainbowDestroy()
    {
        UnityEngine.SceneManagement.SceneManager.LoadScene("Game");

        yield return(new WaitForSeconds(0.1f));

        GameObject spawner = GameObject.Find("SpawningObject");

        GameObject.Destroy(spawner);
        GameObject       blackHexagon = GameObject.FindGameObjectWithTag("Black Hexagon");
        HexagonBehaviour preventInput = blackHexagon.GetComponent <HexagonBehaviour> ();

        preventInput.enabled = false;

        GameObject canvas = GameObject.Find("Canvas");

        yield return(new WaitForSeconds(1f));

        Spawner.angle = 60f;
        yield return(new WaitForSeconds(1f));

        GameObject firstRed = GameObject.Instantiate((GameObject)Resources.Load("Prefabs/RedTrapezoid"), canvas.transform);

        yield return(new WaitForSeconds(1f));

        GameObject secondRed = GameObject.Instantiate((GameObject)Resources.Load("Prefabs/RedTrapezoid"), canvas.transform);

        yield return(new WaitForSeconds(1f));

        Spawner.angle = 180f;

        yield return(new WaitForSeconds(1f));

        GameObject thirdRed = GameObject.Instantiate((GameObject)Resources.Load("Prefabs/RedTrapezoid"), canvas.transform);

        yield return(new WaitForSeconds(1f));

        GameObject fourthRed = GameObject.Instantiate((GameObject)Resources.Load("Prefabs/RedTrapezoid"), canvas.transform);

        yield return(new WaitForSeconds(1f));

        Spawner.angle = 120f;

        yield return(new WaitForSeconds(1f));

        GameObject rainbow = GameObject.Instantiate((GameObject)Resources.Load("Prefabs/RainbowTrapezoid"), canvas.transform);

        yield return(new WaitForSeconds(5f));

        GameObject[] noReds = GameObject.FindGameObjectsWithTag("RedTrapezoid(Clone)");

        Assert.IsTrue(noReds.Length == 0);
    }
示例#9
0
    /* ------------------------------ UPDATING AND WAITING FOR INPUT METHODS ------------------------------  */

    /*       
     *  So far just testing stuff
    **/
    // void FixedUpdate()
    // {
    //     // Save current position, not used yet
    //     positions.Add(transform.position);

    //     // Start ghost/replay --- JUST A TEST SO FAR ---
    //     if(Input.GetKeyDown(KeyCode.R))
    //     {                     
    //         transform.position = positions[replayPositionCounter];
    //         replayPositionCounter++;
    //     }
    // }


    /* ------------------------------ CHECKING AND ANALYSING ENVIRONMENT ------------------------------  */

    /*  
     *  The player checks, if it is standing on a tile; if true, then save the currentTile and tell the current and former tile
    **/
    void OnCollisionEnter(Collision collision)
    {        
        GameObject hexagonObject = collision.gameObject;

        if(hexagonObject.tag == "Tile")
        {
            HexagonBehaviour currentTile = hexagonObject.GetComponent<HexagonBehaviour>();
            occupiedTile = currentTile;         // Save the current tile
            currentTile.GotOccupied(this);      // Tell the currentTile, that this player stands on it            
            AnalyseOccupiedHexagon(currentTile.GetComponent<Hexagon>());            
        }
    }
示例#10
0
    void OnCollisionExit(Collision collision)
    {
        GameObject hexagonObject = collision.gameObject;

        if(hexagonObject.tag == "Tile")
        {
            HexagonBehaviour leftTile = hexagonObject.GetComponent<HexagonBehaviour>();

            leftTile.GotUnoccupied(this);   // Tell the former occupiedTile, that this ball left
            AnalyseUnoccupiedHexagon(occupiedTile.GetComponent<Hexagon>());
        }
    }
示例#11
0
    // Use this for initialization
    void Start()
    {
        arrowShoot = GetComponent <AudioSource>();
        arrowShoot.Stop();

        isShooting = false;
        //characterName = "Amor";
        homeHex            = positon.gameObject.GetComponent <HexagonBehaviour>();
        homeHex.inhabitant = this.gameObject;
        shootingEffect     = this.GetComponent <ParticleSystem> ();
        shootingEffect.Stop();
    }
示例#12
0
    // Draw Hexagon Dungeon
    private void drawHexagonDungeon(HexagonBehaviour hex_behave)
    {
        int temp_x = Mathf.RoundToInt(hex_behave.x_position - camera_position.x);
        int temp_y = Mathf.RoundToInt(hex_behave.y_position - camera_position.y);

        for (int i = 0; i < hex_behave.hexagons.Count; i++)
        {
            Vector2 temp_pos = hex_behave.hexagons[i];
            drawCircle(Mathf.RoundToInt(temp_pos.x) + temp_x, Mathf.RoundToInt(temp_pos.y) + temp_y, hex_behave.size, 60, 0, Color.white);
            drawCircle(Mathf.RoundToInt(temp_pos.x) + temp_x, Mathf.RoundToInt(temp_pos.y) + temp_y, hex_behave.size - 20, 60, 0, Color.white);
        }
    }
示例#13
0
    public IEnumerator checkStackOnTop()
    {
        UnityEngine.SceneManagement.SceneManager.LoadScene("Game");

        yield return(new WaitForSeconds(0.1f));

        GameObject spawner = GameObject.Find("SpawningObject");

        GameObject.Destroy(spawner);
        GameObject       blackHexagon = GameObject.FindGameObjectWithTag("Black Hexagon");
        HexagonBehaviour preventInput = blackHexagon.GetComponent <HexagonBehaviour> ();

        preventInput.enabled = false;

        GameObject canvas = GameObject.Find("Canvas");

        yield return(new WaitForSeconds(1f));

        Spawner.angle = 60f;
        GameObject firstRed = GameObject.Instantiate((GameObject)Resources.Load("Prefabs/RedTrapezoid"), canvas.transform);

        yield return(new WaitForSeconds(1f));

        GameObject firstBlue = GameObject.Instantiate((GameObject)Resources.Load("Prefabs/BlueTrapezoid"), canvas.transform);

        yield return(new WaitForSeconds(1f));

        GameObject secondBlue = GameObject.Instantiate((GameObject)Resources.Load("Prefabs/BlueTrapezoid"), canvas.transform);

        yield return(new WaitForSeconds(1f));

        GameObject droppingYellow = GameObject.Instantiate((GameObject)Resources.Load("Prefabs/YellowTrapezoid"), canvas.transform);

        yield return(new WaitForSeconds(4f));

        Spawner.angle = 120f;

        GameObject lastBlock = GameObject.Instantiate((GameObject)Resources.Load("Prefabs/YellowTrapezoid"), canvas.transform);

        yield return(new WaitForSeconds(1.5f));

        blackHexagon.transform.Rotate(0, 0, 60);
        HexagonBehaviour.areaZero = Quaternion.Euler(0, 0, 60) * (HexagonBehaviour.areaZero - blackHexagon.transform.position) + blackHexagon.transform.position;

        yield return(new WaitForSeconds(1f));

        Assert.IsTrue(lastBlock.GetComponent <TrapezoidTransform> ().row == 4 && lastBlock.GetComponent <TrapezoidTransform> ().side == 5);
    }
示例#14
0
 public bool TryGetHexagonAtPoint(Vector2 position, out HexagonBehaviour hexagonBehaviour)
 {
     for (int i = 0; i < Width; i++)
     {
         for (int j = 0; j < Height; j++)
         {
             if (IsInside(origin: _tileMap[i, j].transform.position, position))
             {
                 hexagonBehaviour = _tileMap[i, j];
                 return(true);
             }
         }
     }
     hexagonBehaviour = null;
     return(false);
 }
示例#15
0
    public IEnumerator checkGravityAfterDestroy()
    {
        UnityEngine.SceneManagement.SceneManager.LoadScene("Game");

        yield return(new WaitForSeconds(0.1f));

        GameObject spawner = GameObject.Find("SpawningObject");

        GameObject.Destroy(spawner);
        GameObject       blackHexagon = GameObject.FindGameObjectWithTag("Black Hexagon");
        HexagonBehaviour preventInput = blackHexagon.GetComponent <HexagonBehaviour> ();

        preventInput.enabled = false;

        GameObject canvas = GameObject.Find("Canvas");

        yield return(new WaitForSeconds(1f));

        Spawner.angle = 60f;
        GameObject firstRed = GameObject.Instantiate((GameObject)Resources.Load("Prefabs/RedTrapezoid"), canvas.transform);

        yield return(new WaitForSeconds(1f));

        GameObject firstBlue = GameObject.Instantiate((GameObject)Resources.Load("Prefabs/BlueTrapezoid"), canvas.transform);

        yield return(new WaitForSeconds(1f));

        GameObject secondBlue = GameObject.Instantiate((GameObject)Resources.Load("Prefabs/BlueTrapezoid"), canvas.transform);

        yield return(new WaitForSeconds(1f));

        GameObject droppingYellow = GameObject.Instantiate((GameObject)Resources.Load("Prefabs/YellowTrapezoid"), canvas.transform);

        yield return(new WaitForSeconds(1f));

        Spawner.angle = 120f;

        GameObject underneathBlue = GameObject.Instantiate((GameObject)Resources.Load("Prefabs/GreenTrapezoid"), canvas.transform);

        yield return(new WaitForSeconds(1f));

        GameObject finalBlue = GameObject.Instantiate((GameObject)Resources.Load("Prefabs/BlueTrapezoid"), canvas.transform);

        yield return(new WaitForSeconds(3f));

        Assert.IsTrue(droppingYellow.GetComponent <TrapezoidTransform> ().row == 1 && droppingYellow.GetComponent <TrapezoidTransform> ().side == 5);
    }
示例#16
0
    public IEnumerator checkBlackHexagonUpdate()
    {
        UnityEngine.SceneManagement.SceneManager.LoadScene("Game");

        yield return(new WaitForSeconds(0.1f));

        GameObject spawner = GameObject.Find("SpawningObject");

        GameObject.Destroy(spawner);
        GameObject       blackHexagon = GameObject.FindGameObjectWithTag("Black Hexagon");
        HexagonBehaviour preventInput = blackHexagon.GetComponent <HexagonBehaviour> ();

        preventInput.enabled = false;

        GameObject canvas = GameObject.Find("Canvas");

        Spawner.angle = 60f;
        GameObject firstRed = GameObject.Instantiate((GameObject)Resources.Load("Prefabs/RedTrapezoid"), canvas.transform);

        yield return(new WaitForSeconds(4));

        Assert.IsTrue(firstRed.GetComponent <TrapezoidTransform> ().row == 0 && firstRed.GetComponent <TrapezoidTransform>().side == 5);
    }
示例#17
0
    // Initialization Event
    void Start()
    {
        // Components
        raw  = gameObject.GetComponent <RawImage>();
        rect = gameObject.GetComponent <RectTransform>();

        // Settings
        update_scale = true;

        // Variables
        background = new Color[screen_width * screen_height];
        colors     = new Color[screen_width * screen_height];
        for (int i = 0; i < colors.Length; i++)
        {
            bool star = Random.Range(0f, 1f) < 0.001f;
            background[i] = Color.black;
            if (star)
            {
                background[i] = Color.white;
            }
        }
        background.CopyTo(colors, 0);

        camera_position = Vector2.zero;

        // Entities
        player_ship = createShip();

        // Texture
        texture            = new Texture2D(screen_width, screen_height, TextureFormat.ARGB32, false);
        texture.filterMode = FilterMode.Point;
        updateScreen();

        // Debug
        fps_counter.GetComponent <RectTransform>().localPosition = new Vector3((-screen_width / 2) + 54, (-screen_height / 2) + 10, 0);
        dungeon = createHexagonDungeon();
    }
示例#18
0
    public IEnumerator checkChangeInSpawnRate()
    {
        UnityEngine.SceneManagement.SceneManager.LoadScene("Game");

        yield return(new WaitForSeconds(0.1f));

        GameObject       blackHexagon = GameObject.FindGameObjectWithTag("Black Hexagon");
        HexagonBehaviour preventInput = blackHexagon.GetComponent <HexagonBehaviour> ();

        preventInput.enabled = false;

        yield return(new WaitForSeconds(11.8f));

        //Prevents all input from being run.


        GameObject[] yellowTrapezoids = GameObject.FindGameObjectsWithTag("YellowTrapezoid(Clone)");
        GameObject[] blueTrapezoids   = GameObject.FindGameObjectsWithTag("BlueTrapezoid(Clone)");
        GameObject[] redTrapezoids    = GameObject.FindGameObjectsWithTag("RedTrapezoid(Clone)");
        GameObject[] greenTrapezoids  = GameObject.FindGameObjectsWithTag("GreenTrapezoid(Clone)");

        Assert.IsTrue((yellowTrapezoids.Length + blueTrapezoids.Length +
                       redTrapezoids.Length + greenTrapezoids.Length) == 5);
    }
示例#19
0
    // Initialization Event
    void Start()
    {
        // Components
        raw  = gameObject.GetComponent <RawImage>();
        rect = gameObject.GetComponent <RectTransform>();

        // Settings
        update_scale = true;

        // Solar Systems
        for (int i = 0; i < 3; i++)
        {
            float      temp_angle       = Random.Range(0, Mathf.PI / 4) + ((120 * i) * Mathf.Deg2Rad);
            float      temp_distance    = Random.Range(25f, 30f);
            GameObject new_solar_system = Instantiate(solar_system_obj);
            new_solar_system.transform.position = new Vector3(Mathf.Cos(temp_angle), Mathf.Sin(temp_angle), 0f) * temp_distance;
        }

        // Hexagons
        colors = new Color[8000 * 8000];
        for (int i = 0; i < colors.Length; i++)
        {
            colors[i] = Color.clear;
        }

        int temp_screen_width  = screen_width;
        int temp_screen_height = screen_height;

        screen_width  = 8000;
        screen_height = 8000;

        texture            = new Texture2D(8000, 8000, TextureFormat.ARGB32, false);
        texture.filterMode = FilterMode.Point;

        dungeon = createHexagonDungeon();
        drawHexagonDungeon(dungeon);

        texture.SetPixels(colors);
        texture.Apply();
        hexagons.texture          = texture;
        hexagons_outlines.texture = texture;

        screen_width  = temp_screen_width;
        screen_height = temp_screen_height;

        // Variables
        background = new Color[screen_width * screen_height];
        colors     = new Color[screen_width * screen_height];
        for (int i = 0; i < colors.Length; i++)
        {
            /*
             * bool star = Random.Range(0f, 1f) < 0.001f;
             * background[i] = Color.black;
             * if (star) {
             *  background[i] = Color.white;
             * }
             */
            background[i] = Color.clear;
        }
        background.CopyTo(colors, 0);

        camera_position = Vector2.zero;

        // Entities
        player_ship = createShip();

        // Texture
        texture            = new Texture2D(screen_width, screen_height, TextureFormat.ARGB32, false);
        texture.filterMode = FilterMode.Point;
        updateScreen();

        // Debug
        fps_counter.GetComponent <RectTransform>().localPosition = new Vector3((-screen_width / 2) + 54, (-screen_height / 2) + 10, 0);
        //dungeon = createHexagonDungeon();
    }
示例#20
0
 public (int i, int j) GetHexagonIndexes(HexagonBehaviour hexagon)
 {
     return(_tileMap.FindIndex(hexagon));
 }
示例#21
0
    void moveNPCs()
    {
        if (isMoving && !isSlowed)
        {
            if (direction == "UpLeft")
            {
                destHex = homeHex.aboveLeft.GetComponent <HexagonBehaviour> ();


                if (destHex.inhabitantType == 0 || destHex.inhabitantType == 2)
                {
                    //Set new Home
                    this.transform.position = homeHex.aboveLeft.transform.position;
                }
            }

            if (direction == "UpRight")
            {
                destHex = homeHex.aboveRight.GetComponent <HexagonBehaviour> ();

                if (destHex.inhabitantType == 0 || destHex.inhabitantType == 2)
                {
                    //Set new Home
                    this.transform.position = homeHex.aboveRight.transform.position;
                }
            }

            if (direction == "Left")
            {
                destHex = homeHex.left.GetComponent <HexagonBehaviour> ();

                if (destHex.inhabitantType == 0 || destHex.inhabitantType == 2)
                {
                    //Set new Home
                    this.transform.position = homeHex.left.transform.position;
                }
            }

            if (direction == "Right")
            {
                destHex = homeHex.right.GetComponent <HexagonBehaviour> ();

                if (destHex.inhabitantType == 0 || destHex.inhabitantType == 2)
                {
                    //Set new Home
                    this.transform.position = homeHex.right.transform.position;
                }
            }

            if (direction == "DownLeft")
            {
                destHex = homeHex.belowLeft.GetComponent <HexagonBehaviour> ();

                if (destHex.inhabitantType == 0 || destHex.inhabitantType == 2)
                {
                    //Set new Home
                    this.transform.position = homeHex.belowLeft.transform.position;
                }
            }

            if (direction == "DownRight")
            {
                destHex = homeHex.belowRight.GetComponent <HexagonBehaviour> ();

                if (destHex.inhabitantType == 0 || destHex.inhabitantType == 2)
                {
                    //Set new Home
                    this.transform.position = homeHex.belowRight.transform.position;
                }
            }

            homeHex.inhabitant     = null;
            homeHex.inhabitantType = 0;

            /*if (destHex.inhabitantType == 2)
             * {
             *
             *      PeopleBehaviour significantOther = destHex.inhabitant.GetComponent<PeopleBehaviour> ();
             *
             *      significantOther.MutuallyAssuredDestruction ();
             *      this.MutuallyAssuredDestruction ();
             *
             * }*/


            homeHex = destHex;
            if (homeHex.gameObject.name == "Deadzone")
            {
                Debug.Log("Omae Wa Shindeiru");
                Destroy(this.gameObject);
            }

            homeHex.inhabitant     = this.gameObject;
            homeHex.inhabitantType = 2;
            positon = destHex.gameObject;
        }


        else if (isSlowed)
        {
            isSlowed = false;
        }
    }
 public void MakeSpell(HexagonBehaviour hexagonBehaviour)
 {
     Hexagon hexa = hexagonBehaviour._hexagon;
     if (hexa != null && (hexa.CurrentState == Hexagon.State.OverEnnemiTargetable || hexa.CurrentState == Hexagon.State.OverSelfTargetable
         || hexa.CurrentState == Hexagon.State.Targetable))
     {
         if (hexagonBehaviour.FinalArea == null)
         {
             hexagonBehaviour.MakeFinalArea();
         }
         SpellManager.GetInstance().ApplyEffects(hexagonBehaviour.FinalArea, hexa);
         PlayBoardManager.GetInstance().Board.ResetBoard();
     }
 }
    public void HighLight()
    {
        Ray ray = CameraManager.GetInstance().Active.ScreenPointToRay(Input.mousePosition);
        RaycastHit rch;
        int layermask = LayerMask.GetMask("Hexagon");
        if (Physics.Raycast(ray, out rch, Mathf.Infinity, layermask))
        {
            HexagonBehaviour hexagonBehaviour = rch.collider.gameObject.GetComponent<HexagonBehaviour>();
            if (hexagonBehaviour != null)
            {
                Hexagon hexa = hexagonBehaviour._hexagon;
                if(hexa != null)
                {
                    if (_previousHexagon != null && _previousHexagonBehaviour != null)
                    {
                        if (_previousHexagon.CurrentState == Hexagon.State.OverAccessible)
                            _previousHexagon.CurrentState = _previousHexagon.PreviousState;

                        if ((_previousHexagon.CurrentState == Hexagon.State.OverSelfTargetable || _previousHexagon.CurrentState == Hexagon.State.OverEnnemiTargetable ||
                             _previousHexagon.CurrentState == Hexagon.State.Targetable) && _previousHexagonBehaviour.FinalArea != null)
                        {
                            for (int i = 0; i < _previousHexagonBehaviour.FinalArea.Count; i++)
                            {
                                if (_previousHexagonBehaviour.FinalArea[i].CurrentState == Hexagon.State.OverSelfTargetable || _previousHexagonBehaviour.FinalArea[i].CurrentState == Hexagon.State.OverEnnemiTargetable)
                                    _previousHexagonBehaviour.FinalArea[i].CurrentState = _previousHexagonBehaviour.FinalArea[i].PreviousState;
                            }
                        }
                    }

                    _previousHexagon = hexa;
                    _previousHexagonBehaviour = hexagonBehaviour;

                    //on mouse enter new hexa
                    if (hexa.CurrentState == Hexagon.State.Targetable)
                    {
                        hexagonBehaviour.MakeFinalArea();
                    }
                    if (hexa.CurrentState == Hexagon.State.Accessible)
                        hexa.CurrentState = Hexagon.State.OverAccessible;
                }
            }
        }
        else
        {
            if (_previousHexagon != null && _previousHexagon.CurrentState != Hexagon.State.Spawnable)
            {
                if ((_previousHexagon.CurrentState == Hexagon.State.OverSelfTargetable || _previousHexagon.CurrentState == Hexagon.State.OverEnnemiTargetable ||
                             _previousHexagon.CurrentState == Hexagon.State.Targetable) && _previousHexagonBehaviour.FinalArea != null)
                {
                    for (int i = 0; i < _previousHexagonBehaviour.FinalArea.Count; i++)
                    {
                        if (_previousHexagonBehaviour.FinalArea[i].CurrentState == Hexagon.State.OverSelfTargetable || _previousHexagonBehaviour.FinalArea[i].CurrentState == Hexagon.State.OverEnnemiTargetable)
                            _previousHexagonBehaviour.FinalArea[i].CurrentState = _previousHexagonBehaviour.FinalArea[i].PreviousState;
                    }
                }
                else
                    _previousHexagon.CurrentState = _previousHexagon.PreviousState;

                _previousHexagon = null;
            }
        }
    }
示例#24
0
    void ShootArrow(string dir)
    {
        switch (dir)
        {
        case "UpLeft":
            destHex = aboveLeft.GetComponent <HexagonBehaviour>();
            break;

        case "UpRight":
            destHex = aboveRight.GetComponent <HexagonBehaviour>();
            break;

        case "Left":
            destHex = left.GetComponent <HexagonBehaviour>();
            break;

        case "Right":
            destHex = right.GetComponent <HexagonBehaviour>();
            break;

        case "DownLeft":
            destHex = belowLeft.GetComponent <HexagonBehaviour>();
            break;

        case "DownRight":
            destHex = belowRight.GetComponent <HexagonBehaviour>();
            break;
        }


        if (destHex.inhabitant == null && destHex.gameObject.name != "Deadzone")
        {
            destHex.ShootArrow(dir);
        }
        else if (destHex.inhabitant != null)
        {
            PeopleBehaviour target = destHex.inhabitant.GetComponent <PeopleBehaviour> ();
            target.isMoving = true;

            switch (dir)
            {
            case "UpLeft":

                destHex.inhabitant.transform.eulerAngles = new Vector3(0, -30, 0);
                target.direction = "DownRight";
                break;

            case "UpRight":

                destHex.inhabitant.transform.eulerAngles = new Vector3(0, 30, 0);
                target.direction = "DownLeft";
                break;

            case "Left":

                destHex.inhabitant.transform.eulerAngles = new Vector3(0, -90, 0);
                target.direction = "Right";
                break;

            case "Right":

                destHex.inhabitant.transform.eulerAngles = new Vector3(0, 90, 0);
                target.direction = "Left";
                break;

            case "DownLeft":

                destHex.inhabitant.transform.eulerAngles = new Vector3(0, -120, 0);
                target.direction = "UpRight";
                break;

            case "DownRight":

                destHex.inhabitant.transform.eulerAngles = new Vector3(0, 120, 0);
                target.direction = "UpLeft";
                break;
            }
        }
    }
示例#25
0
    void moveNPCs()
    {
        if (isMoving && !isSlowed)
        {
            if (direction == "UpLeft")
            {
                destHex = homeHex.aboveLeft.GetComponent <HexagonBehaviour> ();


                if (destHex.inhabitantType == 0 || destHex.inhabitantType == 2)
                {
                    //Set new Home
                    this.transform.position = homeHex.aboveLeft.transform.position;
                }
            }

            if (direction == "UpRight")
            {
                destHex = homeHex.aboveRight.GetComponent <HexagonBehaviour> ();

                if (destHex.inhabitantType == 0 || destHex.inhabitantType == 2)
                {
                    //Set new Home
                    this.transform.position = homeHex.aboveRight.transform.position;
                }
            }

            if (direction == "Left")
            {
                destHex = homeHex.left.GetComponent <HexagonBehaviour> ();

                if (destHex.inhabitantType == 0 || destHex.inhabitantType == 2)
                {
                    //Set new Home
                    this.transform.position = homeHex.left.transform.position;
                }
            }

            if (direction == "Right")
            {
                destHex = homeHex.right.GetComponent <HexagonBehaviour> ();

                if (destHex.inhabitantType == 0 || destHex.inhabitantType == 2)
                {
                    //Set new Home
                    this.transform.position = homeHex.right.transform.position;
                }
            }

            if (direction == "DownLeft")
            {
                destHex = homeHex.belowLeft.GetComponent <HexagonBehaviour> ();

                if (destHex.inhabitantType == 0 || destHex.inhabitantType == 2)
                {
                    //Set new Home
                    this.transform.position = homeHex.belowLeft.transform.position;
                }
            }

            if (direction == "DownRight")
            {
                destHex = homeHex.belowRight.GetComponent <HexagonBehaviour> ();

                if (destHex.inhabitantType == 0 || destHex.inhabitantType == 2)
                {
                    //Set new Home
                    this.transform.position = homeHex.belowRight.transform.position;
                }
            }

            homeHex.inhabitant     = null;
            homeHex.inhabitantType = 0;

            if (destHex.inhabitantType == 2)
            {
                PeopleBehaviour significantOther = destHex.inhabitant.GetComponent <PeopleBehaviour> ();

                significantOther.MutuallyAssuredDestruction();
                this.MutuallyAssuredDestruction();
            }


            homeHex                = destHex;
            homeHex.inhabitant     = this.gameObject;
            homeHex.inhabitantType = 2;
            positon                = destHex.gameObject;
        }


        else if (isSlowed)
        {
            isSlowed = false;
        }
    }
示例#26
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetButtonDown("Fire") && LevelLogic.arrowCount > 0)
        {
            isShooting = !isShooting;
            updateParticles();
        }



        //INPUT MANAGER
        if (isShooting == false)
        {
            if (Input.GetButtonDown("UpLeft"))
            {
                destHex = homeHex.aboveLeft.GetComponent <HexagonBehaviour> ();

                if ((destHex.inhabitant == null) && (destHex.gameObject.name != "Deadzone"))
                {
                    //Set new Home
                    this.transform.position = homeHex.aboveLeft.transform.position;

                    homeHex.inhabitant = null;
                    homeHex            = destHex;
                    homeHex.inhabitant = this.gameObject;
                    positon            = destHex.gameObject;


                    this.transform.eulerAngles = new Vector3(0, 120, 0);

                    SendMessageUpwards("PlayerMoved");
                }
            }

            if (Input.GetButtonDown("UpRight"))
            {
                destHex = homeHex.aboveRight.GetComponent <HexagonBehaviour> ();

                if ((destHex.inhabitant == null) && (destHex.gameObject.name != "Deadzone"))
                {
                    //Set new Home
                    this.transform.position = homeHex.aboveRight.transform.position;

                    homeHex.inhabitant = null;
                    homeHex            = destHex;
                    homeHex.inhabitant = this.gameObject;
                    positon            = destHex.gameObject;

                    this.transform.eulerAngles = new Vector3(0, -120, 0);

                    SendMessageUpwards("PlayerMoved");
                }
            }

            if (Input.GetButtonDown("Left"))
            {
                destHex = homeHex.left.GetComponent <HexagonBehaviour> ();

                if ((destHex.inhabitant == null) && (destHex.gameObject.name != "Deadzone"))
                {
                    //Set new Home
                    this.transform.position = homeHex.left.transform.position;

                    homeHex.inhabitant = null;
                    homeHex            = destHex;
                    homeHex.inhabitant = this.gameObject;
                    positon            = destHex.gameObject;

                    this.transform.eulerAngles = new Vector3(0, 90, 0);

                    SendMessageUpwards("PlayerMoved");
                }
            }

            if (Input.GetButtonDown("Right"))
            {
                destHex = homeHex.right.GetComponent <HexagonBehaviour> ();

                if ((destHex.inhabitant == null) && (destHex.gameObject.name != "Deadzone"))
                {
                    //Set new Home
                    this.transform.position = homeHex.right.transform.position;

                    homeHex.inhabitant = null;
                    homeHex            = destHex;
                    homeHex.inhabitant = this.gameObject;
                    positon            = destHex.gameObject;

                    this.transform.eulerAngles = new Vector3(0, -90, 0);

                    SendMessageUpwards("PlayerMoved");
                }
            }

            if (Input.GetButtonDown("DownLeft"))
            {
                destHex = homeHex.belowLeft.GetComponent <HexagonBehaviour> ();

                if ((destHex.inhabitant == null) && (destHex.gameObject.name != "Deadzone"))
                {
                    //Set new Home
                    this.transform.position = homeHex.belowLeft.transform.position;

                    homeHex.inhabitant = null;
                    homeHex            = destHex;
                    homeHex.inhabitant = this.gameObject;
                    positon            = destHex.gameObject;

                    this.transform.eulerAngles = new Vector3(0, 30, 0);

                    SendMessageUpwards("PlayerMoved");
                }
            }

            if (Input.GetButtonDown("DownRight"))
            {
                destHex = homeHex.belowRight.GetComponent <HexagonBehaviour> ();

                if ((destHex.inhabitant == null) && (destHex.gameObject.name != "Deadzone"))
                {
                    //Set new Home
                    this.transform.position = homeHex.belowRight.transform.position;

                    homeHex.inhabitant = null;
                    homeHex            = destHex;
                    homeHex.inhabitant = this.gameObject;
                    positon            = destHex.gameObject;

                    this.transform.eulerAngles = new Vector3(0, -30, 0);

                    SendMessageUpwards("PlayerMoved");
                }
            }
        }



        if (isShooting == true)
        {
            if (Input.anyKeyDown && LevelLogic.arrowCount > 0)
            {
                string dir = null;
                destHex = homeHex.GetComponent <HexagonBehaviour> ();

                if (Input.GetButtonDown("UpLeft"))
                {
                    dir = "UpLeft";
                    LevelLogic.arrowCount--;
                    isShooting = false;
                    arrowShoot.Play();
                }

                if (Input.GetButtonDown("UpRight"))
                {
                    dir = "UpRight";
                    LevelLogic.arrowCount--;
                    isShooting = false;
                    arrowShoot.Play();
                }

                if (Input.GetButtonDown("Left"))
                {
                    dir = "Left";
                    LevelLogic.arrowCount--;
                    isShooting = false;
                    arrowShoot.Play();
                }

                if (Input.GetButtonDown("Right"))
                {
                    dir = "Right";
                    LevelLogic.arrowCount--;
                    isShooting = false;
                    arrowShoot.Play();
                }

                if (Input.GetButtonDown("DownLeft"))
                {
                    dir = "DownLeft";
                    LevelLogic.arrowCount--;
                    isShooting = false;
                    arrowShoot.Play();
                }

                if (Input.GetButtonDown("DownRight"))
                {
                    dir = "DownRight";
                    LevelLogic.arrowCount--;
                    isShooting = false;
                    arrowShoot.Play();
                }


                destHex.SendMessage("ShootArrow", dir);
                SendMessageUpwards("UpdateStuff");

                updateParticles();
            }
        }
    }
示例#27
0
    /*
     *  Goes through all the hexagons of every platform (which means going through EVERY single hexagon) and add it to the different lists
     *  At the end, give it its individual colour settings
     */
    private void CollectTilesForListsAndColorThem(bool inEditor)
    {
        int tilesCounter = 0;
        for(int i = 0; i < platforms.Count; i++)
        {
            List<Hexagon> platformTiles = platforms[i].GetTilesList();
            for(int k = 0; k < platformTiles.Count; k++)
            {
                Hexagon hexagon = platformTiles[k];
                HexagonBehaviour behaviour = hexagon.GetComponent<HexagonBehaviour>();
                allTiles[tilesCounter] = hexagon;
                tileColors[hexagon] = hexagon.GetColor();                
                bool destroyVFX = true;
                hexagon.SetStandardTile(true);

                if(inEditor && hexagon.GetAudioSource())
                {
                    DestroyImmediate(hexagon.GetAudioSource());
                }
                
                if(hexagon.IsPathTile())
                {
                    SaveHexagonInList(pathTiles, hexagon, hexagon.GetPathNumber());
                    hexagon.SetStandardTile(false);
                    hexagon.SetMaterial(pathHexagons);
                    //hexagon.SetAudio("cracked");
                    //GameObject child = hexagon.transform.GetChild(0).gameObject;
                    //Material material = child.GetComponent<MeshRenderer>().material;
                    //material.EnableKeyword("_NORMALMAP");
                    //material.SetTexture("_BumpMap", crackedHexagonPattern);
                    //material.SetTextureScale("_MainTex", new Vector2(1.95f, 1.95f)); //aka tiling
                    //material.SetTextureOffset("_MainTex", new Vector2(-0.087f, 0.013f));
                    // Debug.Log("texture");
                }

                if(hexagon.IsCrackedTile())
                {
                    SaveHexagonInList(crackedTiles, hexagon, hexagon.GetCrackedNumber());
                    hexagon.SetStandardTile(false);
                    hexagon.SetAudio("cracked");
                    hexagon.SetMaterial(crackedHexagons);
                }

                if(hexagon.IsDistractionTile())
                {
                    SaveHexagonInList(distractionTiles, hexagon, hexagon.GetDistractionNumber());
                    hexagon.SetStandardTile(false);
                    hexagon.SetMaterial(distractionHexagons);

                    if(!hexagon.GetComponent<HexagonDistraction>()) hexagon.gameObject.AddComponent<HexagonDistraction>();

                    hexagon.GetComponent<HexagonDistraction>().GetStarted(hexagon.GetDistractionNumber(), platforms[i].GetAllPlatformTiles(), 
                                                                            allTiles, tileColors, distractionTiles, hexagon);
                }
                else
                {
                    if(inEditor)
                    {
                        HexagonDistraction distractionScript = hexagon.GetComponent<HexagonDistraction>();
                        if(distractionScript)
                        {                           
                            DestroyImmediate(distractionScript);
                        }                            
                    }
                }

                if(hexagon.IsCheckpointTile())
                {
                    SaveHexagonInList(checkpointTiles, hexagon, hexagon.GetCheckpointNumber());
                    hexagon.SetStandardTile(false);
                    hexagon.SetMaterial(checkpointHexagons);
                }

                if(hexagon.IsSpecialTile())
                {                    
                    SaveHexagonInList(specialTiles, hexagon, hexagon.GetSpecialNumber());                    
                    hexagon.SetStandardTile(false);
                    switch (hexagon.GetSpecialNumber()) {
                        case 0: {
                                hexagon.SetMaterial(teleporterHexagons);
                                break;
                            }
                        case 1: {
                                hexagon.SetMaterial(velocityHexagons);
                                break;
                            }
                        case 2: {
                                hexagon.SetMaterial(jumpPadHexagons);
                                break;
                            }
                        case 3: {
                                hexagon.SetMaterial(loosingHexagons);
                                break;
                            }   
                        defaut: {
                                hexagon.SetMaterial(standardHexagons);
                                break;
                            }
                    }
                    if(!hexagon.GetComponent<HexagonSpecial>()) hexagon.gameObject.AddComponent<HexagonSpecial>();
                    HexagonSpecial specialScript = hexagon.GetComponent<HexagonSpecial>();                
                    specialScript.GetStarted(specialTiles, this, hexagon, inEditor);
                    destroyVFX = !specialScript.HasVFX();
                }
                else
                {
                    if(inEditor)
                    {
                        HexagonSpecial specialScript = hexagon.GetComponent<HexagonSpecial>();
                        if(specialScript)
                        {                           
                           DestroyImmediate(specialScript);
                        }                                                    
                    }
                }

                if(hexagon.IsMovingTile())
                {
                    SaveHexagonInList(movingTiles, hexagon, hexagon.GetMovingNumber());
                    hexagon.SetStandardTile(false);
                    hexagon.SetMaterial(movingHexagons);
                    if(!hexagon.GetComponent<HexagonMovingTiles>()) hexagon.gameObject.AddComponent<HexagonMovingTiles>();                    
                }
                else
                {
                    if(inEditor)
                    {
                        HexagonMovingTiles movingTilesScript = hexagon.GetComponent<HexagonMovingTiles>();
                        if(movingTilesScript)
                        {
                            DestroyImmediate(movingTilesScript);
                        }                            
                    }
                }

                if(hexagon.IsStartingTile())
                {
                    SaveHexagonInList(startingTiles, hexagon, hexagon.GetStartingNumber());
                    hexagon.SetStandardTile(false);
                    hexagon.SetMaterial(startingHexagons);
                    hexagon.SetVisualEffect("StartingVFX", inEditor);
                    destroyVFX = false;
                }

                if(hexagon.IsWinningTile())
                {
                    SaveHexagonInList(winningTiles, hexagon, hexagon.GetWinningNumber());
                    hexagon.SetStandardTile(false);
                    hexagon.SetMaterial(winningHexagons);
                    hexagon.SetVisualEffect("WinningVFX", inEditor);
                    destroyVFX = false;
                }

                if(hexagon.IsStandardTile())
                {
                    standardTiles.Add(hexagon);
                    hexagon.SetMaterial(standardHexagons);
                    if(inEditor && hexagon.GetComponent<AudioSource>())
                    {
                        DestroyImmediate(hexagon.GetComponent<AudioSource>());
                    }
                }

                if(inEditor && hexagon.GetComponent<AudioSource>())
                {
                    if(hexagon.GetComponent<AudioSource>().clip == null)
                    {
                        DestroyImmediate(hexagon.GetComponent<AudioSource>());
                    }
                }

                if(destroyVFX && hexagon.GetVisualEffect()) hexagon.DestroyVisualEffect(inEditor);

                Color[] getAllTouchingColors = this.GetComponent<TileColorsTouching>().GiveColorSet(); // get all Colors when the ball for touching and leaving a hexagon
                behaviour.SetColors(getAllTouchingColors); // give current hexagon the set, in order to get its individual color settings
                tilesCounter++;
            }
        }        
    }