Exemple #1
0
    void UpdateFacing(Vector2 delta)
    {
        if (delta.y > 0)
        {
            mFacing = FacingType.Up;
        }
        else if (delta.y < 0)
        {
            mFacing = FacingType.Down;
        }
        else if (delta.x > 0)
        {
            mFacing = FacingType.Right;
        }
        else if (delta.x < 0)
        {
            mFacing = FacingType.Left;
        }

        if (!delta.Equals(Vector2.zero))
        {
            mIsMoving = true;
        }
        else
        {
            mIsMoving = false;
        }
    }
Exemple #2
0
 public bool Adjacent(int cell, FacingType facing, out int adjacent)
 {
     if (!GetLocation(cell, out Point location) || !Adjacent(location, facing, out Point adjacentPoint))
     {
         adjacent = -1;
         return(false);
     }
     else
     {
         return(GetCell(adjacentPoint, out adjacent));
     }
 }
Exemple #3
0
        public bool Adjacent(Point location, FacingType facing, out Point adjacent)
        {
            adjacent = location;
            switch (facing)
            {
            case FacingType.North:
                adjacent.Y--;
                break;

            case FacingType.NorthEast:
                adjacent.X++;
                adjacent.Y--;
                break;

            case FacingType.East:
                adjacent.X++;
                break;

            case FacingType.SouthEast:
                adjacent.X++;
                adjacent.Y++;
                break;

            case FacingType.South:
                adjacent.Y++;
                break;

            case FacingType.SouthWest:
                adjacent.X--;
                adjacent.Y++;
                break;

            case FacingType.West:
                adjacent.X--;
                break;

            case FacingType.NorthWest:
                adjacent.X--;
                adjacent.Y--;
                break;
            }

            return(Contains(adjacent));
        }
Exemple #4
0
 //Used to set the unit info for the facing,side,unitbehaviour, tag and AI
 public void SetUnit(FacingType facing, SideType side, UnitBehaviourType ubt, bool ai = false)
 {
     Facing = facing;
     if (facing == FacingType.Right)
     {
         transform.eulerAngles = new Vector3(0, 180, 0);
     }
     else
     {
         transform.eulerAngles = Vector3.zero;
     }
     Side           = side;
     gameObject.tag = Side.ToString();
     if (CharOwner.SpineAnim == null)
     {
         CharOwner.SpineAnimatorsetup();
     }
     CharOwner.SpineAnim.gameObject.tag = Side.ToString();
     UnitBehaviour = ubt;
 }
Exemple #5
0
        public override void DrawInspector()
        {
            base.DrawInspector();

            theCam = EditorGUILayout.ObjectField
                         ("Camera", theCam, typeof(Camera), true)
                     as Camera;

            orbitObject = EditorGUILayout.ObjectField
                              ("Orbit Object", orbitObject, typeof(Transform), true)
                          as Transform;

            faceObject = (FacingType)EditorGUILayout.EnumPopup("Face Object", faceObject);

            EditorGUILayout.Space();

            DrawOrbitSettings();

            EditorGUILayout.Space();

            DrawRadiusSettings();
        }
Exemple #6
0
    public BattleTileScript GetBattleBestTileInsideTheBattlefield(Vector2Int pos, FacingType facing)
    {
        BattleTileScript res = null;
        int startValue       = pos.y;

        if (facing == FacingType.Left)
        {
            for (int i = startValue; i < YGridSeparator; i++)
            {
                pos.y = i;
                res   = BattleTiles.Where(r => r.Pos == new Vector2Int(pos.x, i)).FirstOrDefault();
                if (res.BattleTileState != BattleTileStateType.Blocked)
                {
                    return(res);
                }
            }
        }
        else
        {
            for (int i = startValue; i >= YGridSeparator; i--)
            {
                pos.y = i;
                res   = BattleTiles.Where(r => r.Pos == pos).FirstOrDefault();
                if (res == null)
                {
                }

                if (res.BattleTileState != BattleTileStateType.Blocked)
                {
                    return(res);
                }
            }
        }

        return(res);
    }
Exemple #7
0
    void UpdateFacing(Vector2 delta)
    {
        if (delta.y > 0)
        {
            mFacing = FacingType.Up;
        }
        else if (delta.y < 0)
        {
            mFacing = FacingType.Down;
        }
        else if (delta.x > 0)
        {
            mFacing = FacingType.Right;
        }
        else if (delta.x < 0)
        {
            mFacing = FacingType.Left;
        }

        if (!delta.Equals(Vector2.zero))
            mIsMoving = true;
        else
            mIsMoving = false;
    }
Exemple #8
0
 public DirectionType(byte id, string name, FacingType facing)
 {
     ID     = id;
     Name   = name;
     Facing = facing;
 }
Exemple #9
0
 /// <summary>
 /// This constructor only is for serialisation.
 /// </summary>
 public SprayEmitter()
 {
     TextureNames = new[] { (CanonicalString)"dummytexture" };
     GobTypeNames = new[] { (CanonicalString)"dummygob" };
     _radius = 15;
     _sprayAngle = MathHelper.PiOver4;
     _facingType = FacingType.Random;
     _initialVelocity = new SimpleCurve();
     _emissionFrequency = 10;
     _numberToCreate = -1;
     _nextBirth = new TimeSpan(-1);
 }
Exemple #10
0
    public void Update()
    {
        // Get latest texture
        if (
            GetComponent <Renderer>() != null &&
            GetComponent <Renderer>().sharedMaterial != null)
        {
            Atlas =
                GetComponent <Renderer>().sharedMaterial.GetTexture("_MainTex");
            // If received new image, make sure it's uptimized and stuff
            if (_previousAtlas != Atlas)
            {
                PrepNewTexture();
            }
        }

        // Get new cell bounds and scaling from layout and animationSet
        LayoutData curLayoutData   = DefaultLayoutData;
        var        layoutComponent = GetComponent <BbSpriteLayout>();

        if (layoutComponent != null && layoutComponent.enabled)
        {
            curLayoutData = layoutComponent.MyLayoutData;
        }
        int currentCell = 0;
        var animation   = GetComponent <BbSpriteAnimation>();

        if (animation != null && animation.enabled)
        {
            currentCell = animation.CurrentCell;
        }
        _cellBounds = curLayoutData.GetCell(
            currentCell,
            (_spriteToCamRotation.y - transform.eulerAngles.y + 360) % 360);
        _scale = curLayoutData.GetCellScale(currentCell, Atlas);

        // Check for reason to update the mesh
        var dirtyMesh = false;

        if (_previousAtlas != Atlas)
        {
            _previousAtlas = Atlas;
            dirtyMesh      = true;
        }
        if (_previousYRotation != transform.eulerAngles.y)
        {
            _previousYRotation = transform.eulerAngles.y;
            dirtyMesh          = true;
        }
        if (_previousCellBounds != _cellBounds)
        {
            _previousCellBounds = _cellBounds;
            dirtyMesh           = true;
        }
        if (_previousMyFacingType != MyFacingType)
        {
            _previousMyFacingType = MyFacingType;
            dirtyMesh             = true;
        }
        if (_previousScale != _scale)
        {
            _previousScale = _scale;
            var cCollider = GetComponent <CapsuleCollider>();
            if (cCollider != null)
            {
                cCollider.center = new Vector3(0, _scale.y / 2, 0);
                cCollider.radius = _scale.x / 2;
                cCollider.height = _scale.y;
            }
            dirtyMesh = true;
        }
        if (_previousSpriteToCamRotation != _spriteToCamRotation)
        {
            _previousSpriteToCamRotation = _spriteToCamRotation;
            dirtyMesh = true;
        }
        if (_previousVerticalOffset != VerticalOffset)
        {
            _previousVerticalOffset = VerticalOffset;
            dirtyMesh = true;
        }
        if (dirtyMesh)
        {
            UpdateMesh();
        }
    }
Exemple #11
0
    public List <BattleTileScript> GetBattleTileInARowToDestination(Vector2Int destPos, FacingType isEnemyOrPlayer, int startingColumn)
    {
        List <BattleTileScript> res = new List <BattleTileScript>();

        if (isEnemyOrPlayer == FacingType.Right)
        {
            for (int i = YGridSeparator <= startingColumn ? startingColumn : YGridSeparator; i <= destPos.y; i++)
            {
                res.Add(GetBattleTile(new Vector2Int(destPos.x, i)));
            }
        }
        else
        {
            for (int i = YGridSeparator > startingColumn ? startingColumn : YGridSeparator - 1; i >= destPos.y; i--)
            {
                res.Add(GetBattleTile(new Vector2Int(destPos.x, i)));
            }
        }
        return(res);
    }