Ejemplo n.º 1
0
    /// <summary>
    ///
    /// </summary>
    /// <param name="directionID">0-Right;1-ForwardRight;...</param>
    public void JumpToward(int directionID)
    {
        if (State != StateEnum.Idle)
        {
            return;
        }

        var deltaIJ       = CellularMap.DirectionIDToDeltaIJ(directionID);
        var destinationIJ = IJ + deltaIJ;

        if (CellularMap.Instance[destinationIJ])
        {
            State             = StateEnum.Jumping;
            _jumpingTime      = 0f;
            StartIJ           = IJ;
            DestinationIJ     = destinationIJ;
            transform.forward = CellularMap.DeltaIJToWorldDirection(deltaIJ);

            if (Animator)
            {
                Animator.SetTrigger("Jump");
                Animator.SetFloat("JumpingSpeed", 1.333f * (27f / 40f) / JumpingDuration);
            }
        }
    }
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="Image">Input image</param>
 /// <param name="Seed">Randomization seed</param>
 /// <param name="NumberOfPoints">Number of points for the painting</param>
 public OilPainting(Bitmap Image, int Seed, int NumberOfPoints)
 {
     Image.ThrowIfNull("Image");
     _Image          = new Bitmap(Image);
     _NumberOfPoints = NumberOfPoints;
     Map             = new CellularMap(Seed, Image.Width, Image.Height, NumberOfPoints);
     SetupImage();
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="Image">Input image</param>
 /// <param name="Seed">Randomization seed</param>
 /// <param name="NumberOfPoints">Number of points for the painting</param>
 public OilPainting(Bitmap Image, int Seed, int NumberOfPoints)
 {
     if (Image == null)
     {
         throw new ArgumentNullException("Image");
     }
     _Image          = new Bitmap(Image);
     _NumberOfPoints = NumberOfPoints;
     Map             = new CellularMap(Seed, Image.Width, Image.Height, NumberOfPoints);
     SetupImage();
 }
Ejemplo n.º 4
0
    public void Move(CellularMap map)
    {
        //move forward
        int[] direction = Helper.DIRECTIONS[(int)m_direction];
        m_row += direction[0];
        m_col += direction[1];
        transform.position = map.GridToWorld(m_row, m_col);
        //rotate
        int turnDirection = map.GetTileState(ref m_row, ref m_col) ? 1 : -1;

        m_direction        = (CardinalDirections)(Helper.BetterMod((int)m_direction + turnDirection, (int)CardinalDirections.END));
        transform.rotation = Quaternion.Euler(0, (int)m_direction * -90, 0);
    }
Ejemplo n.º 5
0
    void Awake()
    {
        Instance = this;

        for (int i = 0; i < CellSize; i++)
        {
            Cells[i] = new GameObject[CellSize];
            for (int j = 0; j < CellSize; j++)
            {
                var cell = PrefabHelper.InstantiateAndReset(HexagonTemplate, transform);
                cell.transform.localPosition = VI * (i - CellSize / 2) + VJ * (j - CellSize / 2);
                cell.name   = "Cell " + i + "," + j;
                Cells[i][j] = cell;
            }
        }

        HexagonTemplate.SetActive(false);
    }
Ejemplo n.º 6
0
    void Awake()
    {
        Instance = this;

        for (int i = 0; i < CellSize; i++)
        {
            Cells[i] = new GameObject[CellSize];
            for (int j = 0; j < CellSize; j++)
            {
                var cell = PrefabHelper.InstantiateAndReset(HexagonTemplate, transform);
                cell.transform.localPosition = VI*(i - CellSize/2) + VJ*(j - CellSize/2);
                cell.name = "Cell " + i + "," + j;
                Cells[i][j] = cell;
            }
        }

        HexagonTemplate.SetActive(false);
    }