Exemplo n.º 1
0
    public void Enter(Unit unit)
    {
        CurrentUnit = unit;
        team        = CurrentUnit.Team;

        hexState = HexState.Untraversable;
    }
Exemplo n.º 2
0
    public void Exit()
    {
        CurrentUnit = null;
        hexState    = HexState.Traversable;

        team = TEAM.neutral;
    }
Exemplo n.º 3
0
 private int valueToInt(SimpleJSON.JSONNode node, string key, HexState hexState = HexState.NONE)
 {
     if (node[key] == null)
     {
         IsValidMainStats = false;
         return(-1);
     }
     else
     {
         string result = node[key];
         if (hexState == HexState.FIRST)
         {
             string firstDigit = result.Substring(0, 1);
             string remainder  = result.Substring(1, result.Length - 1);
             int    first      = HexToInt(firstDigit) * 100000;
             return(int.Parse(remainder) + first);
         }
         else if (hexState == HexState.LEVEL)
         {
             bool hasLetter = result.Any(x => char.IsLetter(x));
             if (hasLetter)
             {
                 return(HexToInt(result)); //will give "garbage" number
             }
             else
             {
                 return(int.Parse(result));
             }
         }
         else //hexState == HexState.None
         {
             return(int.Parse(result));
         }
     }
 }
Exemplo n.º 4
0
    private void MoveEndedB()
    {
        state = HexState.Idle;

        bool isThereAnyMatch = boardManager.RefreshMatchingHexes();

        if (!isThereAnyMatch)
        {
            //DONT Increment gameManager.movementCount
            if (gameManager.rotationCount < 3)
            {
                if (gameManager.lastRotationDirection)
                {
                    gameManager.OnClockWiseSwipe();
                }
                else
                {
                    gameManager.OnCounterClockWiseSwipe();
                }
            }
        }
        else
        {
            gameManager.rotationCount = 3;
            gameManager.IncrementMovementCount();
            foreach (BombBehaviour bb in boardManager.bombsReferences)
            {
                bb.DecrementCountDown();
            }
        }
    }
Exemplo n.º 5
0
 private void setIdle()
 {
     hexStatusState     = HexState.Dead;
     hexProgressState   = HexProgress.Nothing;
     waterBalance       = 0;
     temperatureBalance = 0;
     disasterProgress   = 0;
     disasterState      = DisasterState.None;
 }
Exemplo n.º 6
0
 private HexState[] CreateHexStates()
 {
     HexState[] ret = new HexState[_hexCount];
     for (int i = 0; i < _hexCount; i++)
     {
         ret[i] = new HexState();
     }
     return(ret);
 }
Exemplo n.º 7
0
    public void UpdateWith(HexState other)
    {
        this.visible = other.visible;

        if (!String.IsNullOrEmpty(other.terrain))
        {
            this.terrain = other.terrain;
        }
    }
Exemplo n.º 8
0
 private void setIdle(HexState newHexState)
 {
     this.hexStatusState = newHexState;
     hexProgressState    = HexProgress.Birth;
     waterBalance        = 0;
     temperatureBalance  = 0;
     disasterProgress    = 0;
     disasterState       = DisasterState.None;
 }
Exemplo n.º 9
0
    public void Move(float[] points)
    {
        float y = points[Random.Range(0, points.Length)];

        state       = y == 0 ? HexState.NONE : (y == -3 ? HexState.DOWN : HexState.UP);
        endPosition = new Vector3(transform.position.x, y, transform.position.z);
        if (transform != null)
        {
            transform?.DOMove(endPosition, 0.5f);
        }
    }
Exemplo n.º 10
0
 public BasicHexModel()
 {
     temperatureBalance = 0;
     waterBalance       = 0;
     deltaTemperature   = 0;
     deltaWater         = 0;
     progressPoints     = 0;
     state            = HexState.Dead;
     health           = 100;
     hexProgressState = ProgressState.Nothing;
 }
Exemplo n.º 11
0
 public void ResetAll()
 {
     temperatureBalance = 0;
     waterBalance       = 0;
     deltaTemperature   = 0;
     deltaWater         = 0;
     progressPoints     = 0;
     health             = 0;
     state            = HexState.Dead;
     hexProgressState = ProgressState.Nothing;
 }
Exemplo n.º 12
0
    public void SetHexState(HexState a_hexSate, Color a_colour)
    {
        hexState = a_hexSate;

        if (!highlight)
        {
            highlight = GetComponentsInChildren <SpriteRenderer>()[1];
        }

        highlight.color = a_colour;
    }
Exemplo n.º 13
0
    private void Update()
    {
        HexState hexState = GetHoveredState();

        UpdateHexStates(hexState);
        SetBufferData();

        MapTesterMat.SetTexture("_MainTex", _set.BaseMap);
        MapTesterMat.SetTexture("_BorderTex", _set.BorderMap);
        MapTesterMat.SetBuffer("_NeighborsBuffer", _neighborsBuffer);
        MapTesterMat.SetBuffer("_HexStates", _hexStatesBuffer);
    }
Exemplo n.º 14
0
    private IEnumerator Move()
    {
        state = HexState.Falling;
        moveT = 0.0f;

        while (transform.position != targetPosition)
        {
            transform.position = Vector3.Lerp(transform.position, targetPosition, moveT);
            moveT += Time.deltaTime / moveTime;
            yield return(waitForEndOfFrame);//new WaitForEndOfFrame();
        }
        MoveEnded();
    }
Exemplo n.º 15
0
 private void SetBufferData()
 {
     HexBufferState[] data = new HexBufferState[_hexCount];
     for (int i = 0; i < _hexCount; i++)
     {
         HexState source = _hexStates[i];
         data[i] = new HexBufferState()
         {
             Hover = source.Hover, Clicked = source.Clicked ? 1 : 0
         };
     }
     _hexStatesBuffer.SetData(data);
 }
Exemplo n.º 16
0
    private void UpdateHexStates(HexState hoveredState)
    {
        bool clicked = Input.GetMouseButtonDown(0);

        foreach (HexState state in _hexStates)
        {
            float target = state == hoveredState ? 1f : 0;
            state.Hover = Mathf.Lerp(target, state.Hover, _main.SelectionTestHoverSpeed);
            if (clicked && state == hoveredState)
            {
                state.Clicked = !state.Clicked;
            }
        }
    }
Exemplo n.º 17
0
    // Start is called before the first frame update
    void Start()
    {
        Neighbours = new Dictionary <NeighbourDirection, GameObject>();
        HexState   = HexState.Neutral;

        //for (int i = 0; i < Enum.GetValues(typeof(NeighbourDirection)).Length; i++) {
        //    Vector3 direction = transform.TransformDirection(Vector3.back) * 5;
        //    if (Physics.Raycast(transform.position, direction, out var hit, 20)) {
        //        Debug.Log("Hit: " + hit.collider.name);
        //    }
        //}

        //Debug.Log(Neighbours.Count);
    }
Exemplo n.º 18
0
 public static void InitMap(MapState mapState)
 {
     instance.tilemap.ClearAllTiles();
     foreach (Vector3Int coord in mapState.Coordinates())
     {
         HexState hex = mapState.GetHexState(coord);
         if (!hex.visible)
         {
             instance.tilemap.SetTile(coord, instance.blackTile);
         }
         else if (hex.terrain.Equals("GRASS"))
         {
             instance.tilemap.SetTile(coord, instance.grassTile);
         }
         else
         {
             instance.tilemap.SetTile(coord, instance.waterTile);
         }
     }
     Debug.Log("Map initialized");
 }
Exemplo n.º 19
0
    public void Update()
    {
        HexState hexState = GetHoveredState();

        UpdateHexStates(hexState);
        SetBufferData();

        _main.SelectionTestMat.SetBuffer("_DistortionData", _main.DistortionOutput);
        _main.SelectionTestMat.SetFloat("_SourceImageWidth", _main.BaseTexture.width);
        _main.SelectionTestMat.SetFloat("_SourceImageHeight", _main.BaseTexture.height);
        _main.SelectionTestMat.SetTexture("_MainTex", _main.BaseTexture);
        _main.SelectionTestMat.SetBuffer("_HexStates", _hexStatesBuffer);
        _main.SelectionTestMat.SetFloat("_BorderThickness", _main.BorderThickness);
        _main.SelectionTestMat.SetBuffer("_CornersData", _main.CornerPointsBuffer);
        _main.SelectionTestMat.SetBuffer("_NeighborsBuffer", _main.NeighborsBuffer);
        _main.SelectionTestMat.SetFloat("_MaxIndex", _main.MaxIndex);

        if (_main.DrawCornerDebugLines)
        {
            DrawCorners();
        }
    }
Exemplo n.º 20
0
 public void MakeMeActive()
 {
     battaleState = HexState.active;
 }
Exemplo n.º 21
0
 public void MakeMeActive()// establece el estado activo en este hexagono
 {
     battleHexState = HexState.active;
 }
Exemplo n.º 22
0
 public HexState(HexState state)
 {
     _terrain   = state._terrain;
     _elevation = state._elevation;
     _unit      = new UnitState(state._unit);
 }
Exemplo n.º 23
0
 private void MoveEnded()
 {
     state = HexState.Idle;
     bool isThereAnyMatch = boardManager.RefreshMatchingHexes();
 }
Exemplo n.º 24
0
 // Setter to change state (Dead or Alive)
 public void SetState(HexState newState)
 {
     state = newState;
 }
Exemplo n.º 25
0
 public void MakeMeActive()//sets active state to this hex
 {
     battleHexState = HexState.active;
 }
Exemplo n.º 26
0
    private void DoRay()
    {
        RaycastHit hitInfo;

        if (fwdLastMove)
        {
            Vector3 fwdDir = transform.forward - transform.up;
            Debug.DrawRay(transform.position, fwdDir, Color.red);
            if (Physics.Raycast(transform.position, fwdDir, out hitInfo, 5))
            {
                targetState        = hitInfo.transform.gameObject.GetComponent <HexState>();
                targetHexElevation = targetState.elevation;

                //TODO
                // serialisable movementRules [] = {up, down}
                // for each m in movementRules
                // run the if statement below
                // if(movementRules == targetHexElevation) {canMove = true}
                if (targetHexElevation == HexState.ElevationState.neut) //if elevation in HexState.class is neut
                {
                    canMove = true;
                }
                else
                {
                    canMove = false;
                }
            }
            else
            {
                canMove = false;
            }
        }
        else
        {
            Vector3 bckDir = -transform.forward - transform.up;
            Debug.DrawRay(transform.position, bckDir, Color.red);
            if (Physics.Raycast(transform.position, bckDir, out hitInfo, 5))
            {
                targetState        = hitInfo.transform.gameObject.GetComponent <HexState>();
                targetHexElevation = targetState.elevation;

                if (targetHexElevation == HexState.ElevationState.neut) //if elevation in HexState.class is neut
                {
                    canMove = true;
                }
                else
                {
                    canMove = false;
                }
            }
            else
            {
                canMove = false;
            }
        }

        //if (targetHexElevation == HexState.ElevationState.down || targetHexElevation == HexState.ElevationState.neut)
        //{
        //    canRaise = true;
        //}
        //else if (targetHexElevation == HexState.ElevationState.up || targetHexElevation == HexState.ElevationState.neut)
        //{
        //    canLower = true;
        //}
    }
Exemplo n.º 27
0
 public void MakeActive()
 {
     battleHexState = HexState.active;
 }
Exemplo n.º 28
0
 public void SetHexState(Vector3Int position, HexState hex)
 {
     hexes[position.x + "," + position.y] = hex;
 }