Ejemplo n.º 1
0
 public void RaiseMovementChange(MovementType oldMovement, MovementType newMovement)
 {
     if (MovementChange != null)
     {
         MovementChange(oldMovement, newMovement);
     }
 }
Ejemplo n.º 2
0
        public UnitType(ContentManager contentManager=null,
            string name = "", double maxHealth = 100.0, AttackType attackType = AttackType.Melee,
            double attackStrength = 1.0, double attackRange = 1.0, double attackSpeed = 1.0, double defense = 0.0,
            MovementType movementType = MovementType.Walker,
            double movementSpeed = 1.0, List<Action> actions = null, List<Spell> spells = null, double gatherRate = 10.0,
            double goldCost = 10.0, double ironCost = 0.0, double manaCrystalsCost = 0.0,
            string textureFilename="", int frameWidth=16, int frameHeight=16,
            int[][] idleIndices=null, int[][] walkIndices=null, int[][]attackIndices=null)
        {
            this.name = name;
            this.maxHealth = maxHealth;
            this.attackType = attackType;
            this.attackStrength = attackStrength;
            this.attackRange = attackRange;
            this.attackSpeed = attackSpeed;
            this.defense = defense;
            this.movementType = movementType;
            this.movementSpeed = movementSpeed;
            this.actions = actions ?? new List<Action>();
            this.spells = spells ?? new List<Spell>();
            this.gatherRate = gatherRate;
            this.goldCost = goldCost;
            this.ironCost = ironCost;
            this.manaCrystalsCost = manaCrystalsCost;
            this.textureFilename = textureFilename;
            this.frameWidth = frameWidth;
            this.frameHeight = frameHeight;
            this.idleIndices = idleIndices ?? new [] {new [] { 0 }, new [] { 0 }, new [] { 0 }, new [] { 0 } };
            this.walkIndices = walkIndices ?? new [] { new[] { 0 }, new[] { 0 }, new[] { 0 }, new[] { 0 } };
            this.attackIndices = attackIndices ?? new [] { new[] { 0 }, new[] { 0 }, new[] { 0 }, new[] { 0 } };

            if (contentManager != null) texture = contentManager.Load<Texture2D>(textureFilename);
        }
Ejemplo n.º 3
0
        public readonly int[][] walkIndices; // [RDLU][index]

        #endregion Fields

        #region Constructors

        public UnitType(string name="", double maxHealth=100.0, AttackType attackType=AttackType.Melee,
            double attackStrength=1.0, double attackRange=1.0, double attackSpeed = 1.0, double defense=0.0,
            MovementType movementType=MovementType.Walker,
            double movementSpeed=1.0, List<Action> actions=null, List<Spell> spells=null, double gatherRate = 10.0,
            double goldCost=10.0, double ironCost=0.0, double manaCrystalsCost=0.0,
            Texture2D[] idleTextures=null, Texture2D[] attackTextures=null, Texture2D[] moveTextures=null)
        {
            this.name = name;
            this.maxHealth = maxHealth;
            this.attackType = attackType;
            this.attackStrength = attackStrength;
            this.attackRange = attackRange;
            this.attackSpeed = attackSpeed;
            this.defense = defense;
            this.movementType = movementType;
            this.movementSpeed = movementSpeed;
            this.actions = actions ?? new List<Action>();
            this.spells = spells ?? new List<Spell>();
            this.gatherRate = gatherRate;
            this.goldCost = goldCost;
            this.ironCost = ironCost;
            this.manaCrystalsCost = manaCrystalsCost;
            this.idleTextures = idleTextures ?? new Texture2D[] { };
            this.attackTextures = attackTextures ?? new Texture2D[] { };
            this.moveTextures = moveTextures ?? new Texture2D[] { };
        }
Ejemplo n.º 4
0
        public MovingPlatform(Point startpos, Point sizeInTiles, int amountOfBlocks, MovementType movementType)
            : base(new Vector2(startpos.X * 48, startpos.Y * 48), sizeInTiles)
        {
            this.startPos = startpos;
            this.movement = movementType;
            switch (movementType)
            {
                case MovementType.HORIZONTAL_LEFT:
                    destinationPos = new Point(startpos.X - amountOfBlocks, startpos.Y);
                    break;
                case MovementType.HORIZONTAL_RIGHT:
                    destinationPos = new Point(startpos.X + amountOfBlocks, startpos.Y);
                    break;
                case MovementType.VERTICAL_DOWN:
                    destinationPos = new Point(startpos.X, startpos.Y + amountOfBlocks);
                    break;
                case MovementType.VERTICAL_UP:
                    destinationPos = new Point(startpos.X, startpos.Y - amountOfBlocks);
                    break;
            }

            startVec = new Vector2(startpos.X * 48,
                startpos.Y * 48);
            destinationVec = new Vector2(destinationPos.X * 48,
                destinationPos.Y * 48);
        }
Ejemplo n.º 5
0
        public Orders( BaseFactionGuard guard, GenericReader reader )
        {
            m_Guard = guard;

            int version = reader.ReadEncodedInt();

            switch ( version )
            {
                case 1:
                {
                    m_Follow = reader.ReadMobile();
                    goto case 0;
                }
                case 0:
                {
                    int count = reader.ReadEncodedInt();
                    m_Reactions = new ArrayList( count );

                    for ( int i = 0; i < count; ++i )
                        m_Reactions.Add( new Reaction( reader ) );

                    m_Movement = (MovementType)reader.ReadEncodedInt();

                    break;
                }
            }
        }
Ejemplo n.º 6
0
 public MovementItem(ScreenPoint destination, MovementType type, Directions direction, string animationname)
 {
     this.destination = destination;
     this.type = type;
     this.direction = direction;
     this.animationname = animationname;
 }
 public MovementTypeTemporaryEffect(MovementType movementType, int duration)
 {
     TurnsRemaining = duration;
     _movementType = movementType;
     EffectComplete = false;
     Name = movementType.ToString();
     Id = Guid.NewGuid();
 }
Ejemplo n.º 8
0
 public CharacterData(int health, int speed, MovementType movement, List<Ability> abilities, List<Trait> traits)
 {
     this.health = health;
     this.speed = speed;
     this.movement = movement;
     this.abilities = abilities;
     this.traits = traits;
 }
 public MovementNode(Vector3 startPosition, Vector3 endPosition, MovementType type = MovementType.Straight)
 {
     start = startPosition;
     end = endPosition;
     this.type = type;
     lookPoint = Vector3.zero;
     bezierControl = Vector3.zero;
     travelTime = 0;
 }
Ejemplo n.º 10
0
    private void ResetFields() {
        objToMove = null;
        onFinish = null;
        movement = MovementType.None;

        degreesToSpin = 0f;
        rate = 1.0f;

        shakeCount = 0;
    }
 public static ITraversalStrategy<Cell> GraphAgentFromMovementType(MovementType type, Grid3D graph)
 {
     switch(type)
     {
         case MovementType.Walking:
             return new RuningManAlgorithm(graph);
         default:
             return new RuningManAlgorithm(graph);
     }
 }
Ejemplo n.º 12
0
 public Movement(MovementType type, Point start, Point end, float speed, bool loop)
 {
     Type = type;
       Start = start;
       End = end;
       LastTime = 0;
       Time = 0;
       Duration = speed;
       Loop = loop;
 }
Ejemplo n.º 13
0
 //constructor
 public Obstacle(PrimitiveType primitive, MovementType movement)
 {
     obstacle = GameObject.CreatePrimitive(primitive);
     movementType = movement;
     myZposition = Random.Range(-10f, 10f);
     obstacle.transform.position =
         new Vector3(Random.Range(-10f, 10f),
                     Random.Range(-10f, 10f),
                     Random.Range(-10f, 10f));
 }
Ejemplo n.º 14
0
        public TDCMovement(MovementType mMovement, string[] mAllowedTags, string[] mObstacleTags, string[] mExceptionTags)
        {
            IgnoreEntities = new HashSet<Entity>();
            _obstaclePositions = new List<TDVector2>();

            Movement = mMovement;
            AllowedTags = mAllowedTags;
            ObstacleTags = mObstacleTags;
            ExceptionTags = mExceptionTags;
        }
Ejemplo n.º 15
0
 public StockMovement(Product product, int amount, decimal price, string userId, MovementType movementType)
 {
     Id = Guid.NewGuid().ToString();
     Price = price;
     UserId = userId;
     Amount = amount;
     Product = product;
     Date = DateTime.Now;
     Status = MovementStatus.Created;
     TypeOfMovement = movementType;
 }
Ejemplo n.º 16
0
 public Monster(Monster m)
 {
     name = m.name;
     id = m.id;
     position = m.position;
     up = m.up;
     fixedPath = m.fixedPath;
     waypointId = m.waypointId;
     movement = m.movement;
     armor = m.armor;
     weapon = m.weapon;
     behavior = m.behavior;
 }
Ejemplo n.º 17
0
        private static void CreateMovementState()
        {
            lock (_timer)
            {
                var c = Game.Player.Character;
                var m = c.AgentClientMemory;
                var t = c.Transformation;

                _position = new Position(m.X, m.Y, m.Plane);
                _goal = t.Goal;
                _speedModifier = Game.Player.SpeedModifier;
                _type = t.MovementType;
            }
        }
Ejemplo n.º 18
0
 void Update()
 {
     if (Input.GetAxis ("Stealth") > 0) {
         moveSpeed = stealthSpeed;
         movingState = MovementType.Stealth;
     } else if (Input.GetAxis ("Run") > 0) {
         moveSpeed = runSpeed;
         movingState = MovementType.Running;
     } else {
         moveSpeed = walkSpeed;
         movingState = MovementType.Walking;
     }
     // Actually move the character
     UpdateMovement();
 }
Ejemplo n.º 19
0
        public void Move(MovementType movementType, int newX, int newY)
        {
            if (newX != _xCoordinate) //pawns only move in the Y axis, direction chosen by color, magnitude is always 1 as there is no starting jump rule in this game of 'chess'
                return; // I feel like throwing an exception here, but that aint in the spec.

            if(_pieceColor == PieceColor.Black) //black decreases y to move forward
            {
                if (newY < _yCoordinate && Math.Abs(newY - _yCoordinate) == 1)
                    _yCoordinate = newY;
            }
            else // white increases y to move forward
            {
                if (newY > _yCoordinate && Math.Abs(newY - _yCoordinate) == 1)
                    _yCoordinate = newY;
            }
        }
Ejemplo n.º 20
0
 public MovementNode(
     MovementNode parent, 
     bool isWinningMove, 
     bool isLosingMove,
     string state, 
     MovementType movementType,
     float rotation, 
     int depth)
 {
     this.Parent = parent;
     this.IsWinningMove = isWinningMove;
     this.Rotation = rotation;
     this.IsLosingMove = isLosingMove;
     this.State = state;
     this.MovementType = movementType;
     this.Depth = depth;
 }
Ejemplo n.º 21
0
 public Creature(string name, Vector2 worldIndex, MovementType movementType, Stat hitPoints, Stat mana, ITurnStrategy turnStrategy, IDrawStrategy drawStrategy, IDeathStrategy deathStrategy, IAttackStrategy attackStrategy, World world, IRemains remains)
 {
     MovementType = movementType;
     WorldIndex = worldIndex;
     Name = name;
     Health = hitPoints;
     Mana = mana;
     TurnStrategy = turnStrategy;
     DrawStrategy = drawStrategy;
     DeathStrategy = deathStrategy;
     AttackStrategy = attackStrategy;
     _world = world;
     Inventory = new List<IItem>();
     Spells = new List<ISpell>();
     TemporaryEffects = new List<ITemporaryEffect>();
     ViewDistance = new Stat(15);
     Remains = remains;
 }
Ejemplo n.º 22
0
    //TODO: Place for model data.
    void Start()
    {
        Material Red = (Material)Resources.Load("Temp/Materials/Redfish_MT");
        Material Blue = (Material)Resources.Load("Temp/Materials/Purpfish_MT");
        Material Green = (Material)Resources.Load("Temp/Materials/Goldfish_MT");
        //TODO: Load Model Data
        //TODO: Calculate complexity

        species = GenUtil.species(Random.Range(1,40),complexity:75, targets: Targets.Smaller);
        //Debug.Log (species);

        //Unpack species string
        string[] temp = species.Split(new char[] {' '});
        speciesName = temp[0];
        Diet = (DietType)System.Enum.Parse(typeof(DietType),temp[1]);
        dimensions.x = float.Parse(temp[2]);
        dimensions.y = float.Parse(temp[3]);
        dimensions.z = float.Parse(temp[4]);
        AttType = (AttackType)System.Enum.Parse(typeof(AttackType),temp[5]);
        DefType = (DefenceType)System.Enum.Parse(typeof(DefenceType),temp[6]);
        MovType = (MovementType)System.Enum.Parse(typeof(MovementType),temp[7]);
        targets = (Targets)System.Enum.Parse(typeof(Targets),temp[8]);
        speed = float.Parse(temp[9]);
        if(temp.Length > 10){
            for(int i = 10;i<temp.Length;i++){
                gameObject.AddComponent(temp[i]);
            }
        }
        size = (dimensions.x+dimensions.y+dimensions.z)/3;

        //Switch Color based on Diet
        switch(Diet){
        case DietType.Omnivore:
            renderer.material = Blue;
            break;
        case DietType.Herbivore:
            renderer.material = Green;
            break;
        case DietType.Carnivore:
            renderer.material = Red;
            break;
        }
    }
Ejemplo n.º 23
0
        public void Update(Position position, Position goal, float velocity, MovementType movementType)
        {
            dynamic p = new JObject();
            p.x = position.X;
            p.y = position.Y;
            p.plane = position.Plane;

            dynamic g = new JObject();
            g.x = goal.X;
            g.y = goal.Y;
            g.plane = goal.Plane;

            Send("update", o =>
                    {
                        o.position = p;
                        o.goal = g;
                        o.velocity = velocity;
                        o.move_type = movementType;
                    });
        }
Ejemplo n.º 24
0
	void Start() 
	{
		this.cylinderMovement = GetComponent<CylinderMovement>();
		this.normalMovement = GetComponent<NormalMovement>();
		this.rigidBody = GetComponent<Rigidbody>();
		this.cam = GameObject.FindGameObjectWithTag("MainCamera").GetComponent<CameraController>();

		this.cylinders = GameObject.Find("Cylinders").transform;

		this.eyeObjects = new GameObject[] {
			transform.GetChild(0).FindChild("Left Eye").gameObject,
			transform.GetChild(0).FindChild("Right Eye").gameObject,
			transform.GetChild(0).FindChild("Eye Whites Sprite").gameObject
		};

		GameObject charSprite = transform.GetChild(0).FindChild("Character Sprite").gameObject;
		anim = charSprite.GetComponent<Animator>();

		movementType = MovementType.None;
	}
Ejemplo n.º 25
0
 /// <summary>
 /// Any unit on the map
 /// </summary>
 /// <param name="map">The map the character is on</param>
 /// <param name="name">The characters name, for use in the lookup dictionary</param>
 public Character(GridHandler map, string name)
 {
     this.y = 0;
     this.x = 0;
     this.canAct = false;
     this.canMove = false;
     this.myLocation = null;
     this.map = map;
     this.myAbilities = null;
     this.name = name;
     this.myAbilities = null;
     this.health = 0;
     this.speed = 0;
     this.movement = MovementType.Ground;
     this.myConditions = null;
     this.faction = 0;
     this.characterList = null;
     this.canAct = false;
     this.traitNames = new List<string>();
 }
Ejemplo n.º 26
0
    public void Init(Creature obj, string damage, Color color, MovementType movementType)
    {
        m_movementType = movementType;
        m_target = obj;
        m_targetPos = obj.transform.position+m_target.HPPointTransform.localPosition;
        m_targetPos.y += 1;
        transform.position = m_targetPos;
        m_startTime = Time.time;
        m_posY = 0f;

        m_text = GetComponent<TypogenicText>();
        m_text.Text = damage;
        m_text.ColorTopLeft = color;
        //transform.localScale = Vector3.one/2f;

        if (movementType == MovementType.Parabola || movementType == MovementType.ParabolaAlpha)
        {
            float[] angs = {80,100};
            m_parabola = new Parabola(gameObject, 6f, 0f,angs[Random.Range(0, angs.Length)]*Mathf.Deg2Rad, 1);
        }
    }
Ejemplo n.º 27
0
 public void SetMovementToRotate()
 {
     movementType = MovementType.Rotate;
 }
Ejemplo n.º 28
0
 void LoadSettings()
 {
     aIType       = (AIType)PlayerPrefs.GetInt("AIType");
     movementType = (MovementType)PlayerPrefs.GetInt("MovementType");
 }
Ejemplo n.º 29
0
    //Helper functions for setting up scenes, only for use in Editor
#if UNITY_EDITOR
    public void SetMovementToSlide()
    {
        movementType = MovementType.Slide;
    }
Ejemplo n.º 30
0
 void INotifyMoving.MovementTypeChanged(Actor self, MovementType types)
 {
     UpdateAnimation(self, types);
 }
Ejemplo n.º 31
0
 public MovementModifier(MovementType type, int speedAdjustment, string name)
 {
     Type       = type;
     Adjustment = speedAdjustment;
     Name       = name;
 }
    void FillModifyData()
    {
        characterName  = characterToModify.name;
        characterLayer = characterToModify.layer;
        characterTag   = characterToModify.tag;
        if (characterToModify.GetComponent <Player_CharacterController>() != null)
        {
            playerOrNPC = PlayerOrNPC.player;
            if (characterToModify.GetComponent <Player_CharacterController>().clickToMove)
            {
                movementType = MovementType.ClickToMove;
            }
            else
            {
                movementType = MovementType.WASD;
            }
        }
        if (characterToModify.GetComponent <NPC_CharacterController>() != null)
        {
            playerOrNPC = PlayerOrNPC.NPC;
            if (characterToModify.GetComponent <NPC_CharacterController>().friendOrFoe == NPC_CharacterController.FriendOrFoe.enemy)
            {
                friendOrFoe = FriendOrFoe.enemy;
                if (characterToModify.GetComponent <NPC_CharacterController>().patrolType == State_Patrol.PatrolType.Circular)
                {
                    patrolType = PatrolType.circular;
                }
                if (characterToModify.GetComponent <NPC_CharacterController>().patrolType == State_Patrol.PatrolType.ForthAndBack)
                {
                    patrolType = PatrolType.forthAndBack;
                }
                if (characterToModify.GetComponent <NPC_CharacterController>().patrolType == State_Patrol.PatrolType.Roam)
                {
                    patrolType = PatrolType.roam;
                }
                patrolObject = characterToModify.GetComponent <NPC_CharacterController>().patrolPointsObject.transform;
                attackRange  = characterToModify.GetComponent <Character>().attackRange;
            }
            else
            {
                friendOrFoe = FriendOrFoe.friendly;
            }
        }
        if (characterToModify.GetComponent <Animator>().runtimeAnimatorController != null)
        {
            animator = characterToModify.GetComponent <Animator>().runtimeAnimatorController;
        }
        if (characterToModify.GetComponent <Character>().mainHand != null)
        {
            useSpecifiedTransformForHands.target = true;
            mainHand = characterToModify.GetComponent <Character>().mainHand;
        }
        if (characterToModify.GetComponent <Character>().offHand != null)
        {
            useSpecifiedTransformForHands.target = true;
            offHand = characterToModify.GetComponent <Character>().offHand;
        }
        if (characterToModify.GetComponent <Character>().attackPoint != null)
        {
            attackPoint = characterToModify.GetComponent <Character>().attackPoint;
        }
        baseSpeed = characterToModify.GetComponent <Character>().baseSpeed;

        if (characterToModify.GetComponent <Player_CharacterController>() != null && characterToModify.GetComponent <Player_CharacterController>().usesFieldOfView || characterToModify.GetComponent <NPC_CharacterController>() != null && characterToModify.GetComponent <NPC_CharacterController>().usesFieldOfView)
        {
            shouldUseFieldOfView.target = true;
            if (playerOrNPC == PlayerOrNPC.player)
            {
                fieldOfViewMat = characterToModify.GetComponent <Player_CharacterController>().filter.gameObject.GetComponent <MeshRenderer>().sharedMaterial;

                //Some way to get the obstacle and target layer here

                obstacleLayer = Mathf.RoundToInt(Mathf.Log(characterToModify.GetComponent <Player_CharacterController>().obstacleAndTargetMasks[0].value, 2));
                targetLayer   = Mathf.RoundToInt(Mathf.Log(characterToModify.GetComponent <Player_CharacterController>().obstacleAndTargetMasks[1].value, 2));

                fieldOfViewRadius = Mathf.RoundToInt(characterToModify.GetComponent <Player_CharacterController>().viewRadiusAnglesResolution.x);
                fieldOfViewAngle  = Mathf.RoundToInt(characterToModify.GetComponent <Player_CharacterController>().viewRadiusAnglesResolution.y);
            }
            else
            {
                fieldOfViewMat = characterToModify.GetComponent <NPC_CharacterController>().fowFilter.gameObject.GetComponent <MeshRenderer>().sharedMaterial;

                //Some way to get the obstacle and target layer here
                obstacleLayer = Mathf.RoundToInt(Mathf.Log(characterToModify.GetComponent <NPC_CharacterController>().obstaclesAndTargetMasks[0].value, 2));
                targetLayer   = Mathf.RoundToInt(Mathf.Log(characterToModify.GetComponent <NPC_CharacterController>().obstaclesAndTargetMasks[1].value, 2));

                fieldOfViewRadius = Mathf.RoundToInt(characterToModify.GetComponent <NPC_CharacterController>().viewRadiusAnglesResolution.x);
                fieldOfViewAngle  = Mathf.RoundToInt(characterToModify.GetComponent <NPC_CharacterController>().viewRadiusAnglesResolution.y);
            }
        }

        foreach (Transform transform in characterToModify.GetComponentInChildren <Transform>())
        {
            if (transform.gameObject.name == "CharacterModel")
            {
                characterModel = transform.gameObject;
            }
        }
    }
Ejemplo n.º 33
0
        public void DrawGamePlayer(ObjectId playerId, ModelId bodyType, Location3D location, Direction direction, MovementType movementType, Color color)
        {
            DrawGamePlayerPacket drawGamePlayerPacket = new DrawGamePlayerPacket(playerId, bodyType,
                                                                                 location, direction, movementType, color);

            Send(drawGamePlayerPacket.RawPacket);
        }
Ejemplo n.º 34
0
 public void SetMovementToScaleZ()
 {
     movementType = MovementType.ScaleZ;
 }
Ejemplo n.º 35
0
        private bool LineCheck(float x1, float y1, float x2, float y2, int checkType, MovementType movementType)
        {
            float x     = x1;
            float y     = y1;
            float dx    = Math.Abs(x2 - x1);
            float dy    = Math.Abs(y2 - y1);
            float stepX = 0;
            float stepY = 0;
            int   steps = (int)Math.Max(dx, dy);

            if (dx > dy)
            {
                stepX = 1;
                stepY = dy / dx;
            }
            else
            {
                stepY = 1;
                stepX = dx / dy;
            }
            if (x1 > x2)
            {
                stepX = -stepX;
            }
            if (y1 > y2)
            {
                stepY = -stepY;
            }
            if (checkType == CHECK_SIGHT)
            {
                for (int i = 0; i < steps; i++)
                {
                    x += stepX;
                    y += stepY;
                    if (IsWall(x, y))
                    {
                        return(false);
                    }
                }
            }
            else if (checkType == CHECK_MOVEMENT)
            {
                for (int i = 0; i < steps; i++)
                {
                    x += stepX;
                    y += stepY;
                    if (!IsValidPosition(x, y, movementType, false))
                    {
                        return(false);
                    }
                }
            }
            return(true);
        }
Ejemplo n.º 36
0
 public PathRequest(Vector3 a, Vector3 b, int mapId, PathRequestFlags flags = PathRequestFlags.None, MovementType movementType = MovementType.MOVE_TO_POSITION)
 {
     A            = a;
     B            = b;
     MapId        = mapId;
     Flags        = flags;
     MovementType = movementType;
 }
Ejemplo n.º 37
0
 public void SetMovementToScaleX()
 {
     movementType = MovementType.ScaleX;
 }
Ejemplo n.º 38
0
        private bool SmallStepForcedSlid(ref float x, ref float y, float stepX, float stepY, MovementType movementType, bool hero)
        {
            const float epsilon = 0.01f;

            if (stepX != 0)
            {
                float dy = y - (float)Math.Floor(y);

                if (IsValidTile((int)x, (int)y + 1, movementType, hero) &&
                    IsValidTile((int)x + sgn(stepX), (int)y + 1, movementType, hero) &&
                    dy > 0.5)
                {
                    y += Math.Min(1 - dy + epsilon, (float)(Math.Abs(stepX)));
                }
                else if (IsValidTile((int)x, (int)y - 1, movementType, hero) &&
                         IsValidTile((int)x + sgn(stepX), (int)y - 1, movementType, hero) &&
                         dy < 0.5)
                {
                    y -= Math.Min(dy + epsilon, (float)(Math.Abs(stepX)));
                }
                else
                {
                    return(false);
                }
            }
            else if (stepY != 0)
            {
                float dx = x - (float)Math.Floor(x);

                if (IsValidTile((int)x + 1, (int)y, movementType, hero) &&
                    IsValidTile((int)x + 1, (int)y + sgn(stepY), movementType, hero) &&
                    dx > 0.5)
                {
                    x += Math.Min(1 - dx + epsilon, (float)(Math.Abs(stepY)));
                }
                else if (IsValidTile((int)x - 1, (int)y, movementType, hero) &&
                         IsValidTile((int)x - 1, (int)y + sgn(stepY), movementType, hero) &&
                         dx < 0.5)
                {
                    x -= Math.Min(dx + epsilon, (float)(Math.Abs(stepY)));
                }
                else
                {
                    return(false);
                }
            }
            else
            {
            }
            return(true);
        }
Ejemplo n.º 39
0
 private void DisplayCurrentFrameInternal(MovementType movementType, Pixelmap currentPixelmap, string frameFileName)
 {
     if (m_VideoStream != null)
     {
         if (m_CurrentFrameIndex >= m_VideoStream.FirstFrame &&
             m_CurrentFrameIndex <= m_VideoStream.LastFrame)
         {
             m_FrameRenderer.RenderFrame(m_CurrentFrameIndex, currentPixelmap, movementType, m_CurrentFrameIndex == m_VideoStream.LastFrame, 0, m_CurrentFrameIndex, frameFileName);
             m_LastDisplayedFrameIndex = m_CurrentFrameIndex;
         }
     }
 }
Ejemplo n.º 40
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="a"></param>
 /// <param name="b"></param>
 /// <returns></returns>
 public static bool HasFlag(MovementType a, MovementType b)
 {
     return (a & b) == b;
 }
Ejemplo n.º 41
0
 public static bool HasMovementType(this MovementType m, MovementType movementType)
 {
     // PERF: Enum.HasFlag is slower and requires allocations.
     return((m & movementType) == movementType);
 }
Ejemplo n.º 42
0
 public void SetMovementType(MovementType moveType)
 {
     MoveType = moveType;
 }
Ejemplo n.º 43
0
 public void SetMovementToScaleY()
 {
     movementType = MovementType.ScaleY;
 }
Ejemplo n.º 44
0
        internal static Vector2 InternalCalculateOffset(ref Bounds viewBounds, ref Bounds contentBounds, bool horizontal, bool vertical, MovementType movementType, ref Vector2 delta)
        {
            Vector2 offset = Vector2.zero;

            if (movementType == MovementType.Unrestricted)
            {
                return(offset);
            }

            Vector2 min = contentBounds.min;
            Vector2 max = contentBounds.max;

            if (horizontal)
            {
                min.x += delta.x;
                max.x += delta.x;
                if (min.x > viewBounds.min.x)
                {
                    offset.x = viewBounds.min.x - min.x;
                }
                else if (max.x < viewBounds.max.x)
                {
                    offset.x = viewBounds.max.x - max.x;
                }
            }

            if (vertical)
            {
                min.y += delta.y;
                max.y += delta.y;
                if (max.y < viewBounds.max.y)
                {
                    offset.y = viewBounds.max.y - max.y;
                }
                else if (min.y > viewBounds.min.y)
                {
                    offset.y = viewBounds.min.y - min.y;
                }
            }

            return(offset);
        }
Ejemplo n.º 45
0
 private bool SmallStepForcedSlideAlongGrid(ref float x, ref float y, float stepX, float stepY, MovementType movementType, bool hero)
 {
     if (IsValidPosition(x + stepX, y, movementType, hero))
     {
         if (stepX == 0)
         {
             return(true);
         }
         x += stepX;
     }
     else if (IsValidPosition(x, y + stepY, movementType, hero))
     {
         if (stepY == 0)
         {
             return(true);
         }
         y += stepY;
     }
     else
     {
         return(false);
     }
     return(true);
 }
Ejemplo n.º 46
0
        public bool ComputePath(float x1, float y1, float x2, float y2, IList <FPoint> path, MovementType movementType, int limit = 0)
        {
            if (IsOutsideMap(x2, y2))
            {
                return(false);
            }
            path.Clear();
            if (limit == 0)
            {
                limit = w * h;
            }
            FPoint startPos        = new FPoint(x1, y1);
            FPoint endPos          = new FPoint(x2, y2);
            Point  start           = Utils.MapToCollision(startPos);
            Point  end             = Utils.MapToCollision(endPos);
            bool   targetBlocks    = false;
            int    targetBlockType = colMap[end.X, end.Y];

            if (targetBlockType == BLOCKS_ENTITIES || targetBlockType == BLOCKS_ENEMIES)
            {
                targetBlocks = true;
                Unblock(end.X, end.Y);
            }
            Point     current = start;
            AStarNode node    = new AStarNode(start);

            node.ActualCost    = 0;
            node.EstimatedCost = Utils.CalcDist(start, end);
            node.Parent        = current;
            AStarContainer      open  = new AStarContainer(w, h, limit);
            AStarCloseContainer close = new AStarCloseContainer(w, h, limit);

            open.Add(node);
            while (!open.IsEmpty && close.Size < limit)
            {
                node      = open.GetShortestF();
                current.X = node.X;
                current.Y = node.Y;
                close.Add(node);
                open.Remove(node);
                if (current.X == end.X && current.Y == end.Y)
                {
                    break;
                }
                List <Point> neighbours = node.GetNeighbours(w, h);
                foreach (Point neighbour in neighbours)
                {
                    if (open.Size >= limit)
                    {
                        break;
                    }
                    if (!IsValidTile(neighbour.X, neighbour.Y, movementType, false))
                    {
                        continue;
                    }
                    if (close.Exists(neighbour))
                    {
                        continue;
                    }
                    if (!open.Exists(neighbour))
                    {
                        AStarNode newNode = new AStarNode(neighbour);
                        newNode.ActualCost    = node.ActualCost + Utils.CalcDist(current, neighbour);
                        newNode.Parent        = current;
                        newNode.EstimatedCost = Utils.CalcDist(neighbour, end);
                        open.Add(newNode);
                    }
                    else
                    {
                        AStarNode i = open.Get(neighbour.X, neighbour.Y);
                        if (node.ActualCost + Utils.CalcDist(current, neighbour) < i.ActualCost)
                        {
                            Point pos        = new Point(i.X, i.Y);
                            Point parent_pos = new Point(node.X, node.Y);
                            open.UpdateParent(pos, parent_pos, node.ActualCost + Utils.CalcDist(current, neighbour));
                        }
                    }
                }
            }
            if (!(current.X == end.X && current.Y == end.Y))
            {
                node      = close.GetShortestH();
                current.X = node.X;
                current.Y = node.Y;
            }
            while (!(current.X == start.X && current.Y == start.Y))
            {
                path.Add(Utils.CollisionToMap(current));
                current = close.Get(current.X, current.Y).Parent;
            }

            if (targetBlocks)
            {
                Block(end.X, end.Y, targetBlockType == BLOCKS_ENEMIES);
            }
            //if (path.Count > 0 && !IsValidTile(end.X, end.Y, movementType))
            //{
            //    path.RemoveAt(0);
            //}
            return(path.Count > 0);
        }
Ejemplo n.º 47
0
            public static void test()
            {
                Graph g = new Graph();

                //this is a constants lookup table
                //to see how each movementtype move on each terrain
                Dictionary <MovementType, Dictionary <TerrainType, int> > TravelCost = new Dictionary <MovementType, Dictionary <TerrainType, int> >();

                TravelCost.Add(MovementType.Soldier, new Dictionary <TerrainType, int>());
                TravelCost[MovementType.Soldier].Add(TerrainType.Plain, 1);
                TravelCost[MovementType.Soldier].Add(TerrainType.Road, 1);
                TravelCost[MovementType.Soldier].Add(TerrainType.Forest, 1);
                TravelCost[MovementType.Soldier].Add(TerrainType.Mountain, 2);
                TravelCost[MovementType.Soldier].Add(TerrainType.Sea, int.MaxValue);

                TravelCost.Add(MovementType.Track, new Dictionary <TerrainType, int>());
                TravelCost[MovementType.Track].Add(TerrainType.Plain, 1);
                TravelCost[MovementType.Track].Add(TerrainType.Road, 1);
                TravelCost[MovementType.Track].Add(TerrainType.Forest, 2);
                TravelCost[MovementType.Track].Add(TerrainType.Mountain, int.MaxValue);
                TravelCost[MovementType.Track].Add(TerrainType.Sea, int.MaxValue);


                //the demo map
                var map = new Map(6, 6);

                map.Fill(TerrainType.Plain);

                //the demo unit
                Point start = new Point(2, 2);
                //Unit unit = new Unit(UnitType.Soldier, null, Owner.Red);
                Unit         unit         = new Unit(UnitType.Tank, null, Owner.Red);
                MovementType movementtype = unit.UnitType.GetMovementType();
                int          maxcost      = 0;

                Owner local = Owner.Red;

                map[0, 0].terrain = TerrainType.Mountain;
                map[1, 0].terrain = TerrainType.Mountain;
                map[2, 0].terrain = TerrainType.Mountain;

                map[3, 1].terrain = TerrainType.Forest;
                map[3, 2].terrain = TerrainType.Forest;

                map[1, 2].unit = new Unit(UnitType.Soldier, null, Owner.Blue);

                map[1, 3].terrain = TerrainType.Sea;
                map[2, 3].terrain = TerrainType.Sea;


                //max movement cost of the unit
                switch (unit.UnitType)
                {
                case UnitType.Soldier:
                    maxcost = 3;
                    break;

                case UnitType.Tank:
                    maxcost = 6;
                    break;

                default:
                    break;
                }


                //init graph
                //just check if a point is connect to nearby point
                //this will be calculated with the map
                for (int y = 0; y < map.Height; y++)
                {
                    for (int x = 0; x < map.Width; x++)
                    {
                        Point currentPoint = new Point(x, y);
                        Point east         = currentPoint.GetNearbyPoint(Direction.East)
                        , west             = currentPoint.GetNearbyPoint(Direction.West)
                        , south            = currentPoint.GetNearbyPoint(Direction.South)
                        , north            = currentPoint.GetNearbyPoint(Direction.North);

                        Dictionary <string, int> temp = new Dictionary <string, int>();
                        if (map[east] != null)
                        {
                            temp.Add(east.toString(), 0);
                        }
                        if (map[west] != null)
                        {
                            temp.Add(west.toString(), 0);
                        }
                        if (map[north] != null)
                        {
                            temp.Add(north.toString(), 0);
                        }
                        if (map[south] != null)
                        {
                            temp.Add(south.toString(), 0);
                        }
                        var t = currentPoint.toString();//, converter);
                        g.add_vertex(t, temp);
                    }
                }

                //serialize navgraph
                string navgraph = JsonConvert.SerializeObject(g.Vertices.ToArray(), Formatting.Indented);

                File.WriteAllText("navgraph.txt", navgraph);

                //deserialize navgraph
                Dictionary <string, Dictionary <string, int> > navgg = new Dictionary <string, Dictionary <string, int> >();

                JsonConvert.DeserializeObject <KeyValuePair <string, Dictionary <string, int> >[]>(navgraph).ToList().ForEach(kvp => { navgg.Add(kvp.Key, kvp.Value); });


                //now we assign aproriate travel cost
                //based on terrain and movementtype
                List <string> vertices = g.Vertices.Keys.ToList();

                foreach (string vertex in vertices)
                {
                    List <string> neighbors = g.Vertices[vertex].Keys.ToList();
                    foreach (string neighbor in neighbors)
                    {
                        Point point = neighbor.Parse();
                        int   cost  = TravelCost[movementtype][map[point].terrain];
                        if (cost < int.MaxValue)
                        {
                            g.Vertices[vertex][neighbor] = cost;
                        }
                        else
                        {
                            g.Vertices[vertex].Remove(neighbor);
                        }
                    }
                }

                //start the dijkstra algorithm
                g.Dijkstra(start.toString());

                //find reachable vertex with the unit's max movement cost
                var range = g.FindReachableVertex();
            }
    private void OnGUI()
    {
        // --- GUI Styles ---
        GUIStyle textStyle1 = new GUIStyle();

        textStyle1.fontSize  = 12;
        textStyle1.fontStyle = FontStyle.Italic;

        GUIStyle title = new GUIStyle();

        title.fontSize  = 14;
        title.fontStyle = FontStyle.Bold;

        GUIStyle boldText = new GUIStyle();

        boldText.margin.left = 3;
        boldText.fontStyle   = FontStyle.Bold;


        // --- ---

        // --- Introduction! ---
        EditorGUILayout.Space();
        GUILayout.BeginHorizontal();
        GUILayout.FlexibleSpace();
        if (createOrModify == CreateOrModify.modify)
        {
            GUILayout.Label("Character Modification", title);
        }
        else
        {
            GUILayout.Label("Character Creation", title);
        }
        GUILayout.FlexibleSpace();
        GUILayout.EndHorizontal();
        EditorGUILayout.Space();
        // --- ---

        EditorGUI.BeginChangeCheck();
        createOrModify = (CreateOrModify)EditorGUILayout.EnumPopup("Create or Modify", createOrModify);
        if (createOrModify == CreateOrModify.create && EditorGUI.EndChangeCheck())
        {
            ResetCreationData();
        }


        if (createOrModify == CreateOrModify.create)
        {
            modifyCharacter.target = false;
        }
        else
        {
            modifyCharacter.target = true;
        }

        if (EditorGUILayout.BeginFadeGroup(modifyCharacter.faded))
        {
            EditorGUI.indentLevel++;

            EditorGUI.BeginChangeCheck();
            characterToModify = EditorGUILayout.ObjectField("Character to modify", characterToModify, typeof(GameObject), true) as GameObject;
            if (characterToModify != null && EditorGUI.EndChangeCheck())
            {
                FillModifyData();
            }

            EditorGUI.indentLevel--;
        }
        EditorGUILayout.EndFadeGroup();
        DrawHorizontalUILine(Color.gray, 1, 4, 45);
        EditorGUILayout.Space();

        // --- Character centered information ---
        GUILayout.Label("Character Information", boldText);

        characterName = EditorGUILayout.TextField(new GUIContent("Character Name"), characterName);

        characterLayer = EditorGUILayout.LayerField(new GUIContent("Layer for the character", "This is optional but reccomended"), characterLayer);
        characterTag   = EditorGUILayout.TagField(new GUIContent("Tag for the character", "This is optional but reccomended"), characterTag);
        maxHealth      = EditorGUILayout.IntField(new GUIContent("Max health", "Will default to 100"), maxHealth);


        // --- ---

        // --- Logic centered information ---

        if (createOrModify == CreateOrModify.create)
        {
            playerOrNPC = (PlayerOrNPC)EditorGUILayout.EnumPopup("Player or NPC", playerOrNPC);
        }


        if (playerOrNPC == PlayerOrNPC.player)
        {
            showNPCCenteredInfo.target    = false;
            showPlayerCenteredInfo.target = true;
        }
        else
        {
            showNPCCenteredInfo.target    = true;
            showPlayerCenteredInfo.target = false;
        }

        // --- Player centered logic ---
        if (EditorGUILayout.BeginFadeGroup(showPlayerCenteredInfo.faded))
        {
            DrawHorizontalUILine(Color.gray, 1, 4, 45);
            GUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            GUILayout.Label("Player centered logic", textStyle1);
            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();
            EditorGUI.indentLevel++;

            movementType = (MovementType)EditorGUILayout.EnumPopup("Movement Type", movementType);

            EditorGUI.indentLevel--;
            DrawHorizontalUILine(Color.gray, 1, 4, 45);
        }
        EditorGUILayout.EndFadeGroup();
        // ---

        // --- NPC centered Logic ---
        if (EditorGUILayout.BeginFadeGroup(showNPCCenteredInfo.faded))
        {
            DrawHorizontalUILine(Color.gray, 1, 4, 45);
            GUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            GUILayout.Label("NPC centered logic", textStyle1);
            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();
            EditorGUI.indentLevel++;

            //As Friendly NPC Logic is not implemented, we will not allow for this for now and will instead just set friendOrFoe to enemy.
            //friendOrFoe = (FriendOrFoe)EditorGUILayout.EnumPopup("Friendly or Enemy", friendOrFoe);
            friendOrFoe = FriendOrFoe.enemy;
            // This will be fixed by removing the friendOrFoe = enemy and uncommenting the line above it when friendly Logic has been implemented

            if (friendOrFoe == FriendOrFoe.enemy)
            {
                patrolType   = (PatrolType)EditorGUILayout.EnumPopup("Patrol Type", patrolType);
                patrolObject = EditorGUILayout.ObjectField(new GUIContent("Patrol object", "If patrol type != 'Roam', this is the parent object and will need the patrol points childed. If it is, this will be the center of the roam patrol"), patrolObject, typeof(Transform), true) as Transform;
                if (patrolType == PatrolType.roam)
                {
                    roaming.target = true;
                }
                else
                {
                    roaming.target = false;
                }
                if (EditorGUILayout.BeginFadeGroup(roaming.faded))
                {
                    EditorGUI.indentLevel++;
                    roamRadius = EditorGUILayout.FloatField(new GUIContent("Radius", "The radius of the roam patrol type"), roamRadius);
                    EditorGUI.indentLevel--;
                }
                EditorGUILayout.EndFadeGroup();
            }
            else
            {
                EditorGUILayout.HelpBox("Friendly NPC behaviour has not been implemented yet, and will be coming shortly", MessageType.Info);
            }

            attackRange = EditorGUILayout.FloatField(new GUIContent("Attack range", "The range an enemy will need to be from the player to start attacking. It is defaulted to 5 because of the reach of the attack"), attackRange);


            EditorGUI.indentLevel--;
            DrawHorizontalUILine(Color.gray, 1, 4, 45);
        }
        EditorGUILayout.EndFadeGroup();
        // ---

        EditorGUILayout.Space();

        baseSpeed = EditorGUILayout.Slider(new GUIContent("Base speed", "Base speed before any modification. This is in units traveled per second"), baseSpeed, 3.5f, 15f);

        // --- ---

        // --- Advanced character information ---
        advancedCharacterInfo = EditorGUILayout.Foldout(advancedCharacterInfo, "Advanced character info", true);
        if (advancedCharacterInfo)
        {
            EditorGUI.indentLevel++;

            if (createOrModify != CreateOrModify.modify)
            {
                appendIDToName.target = EditorGUILayout.ToggleLeft(new GUIContent("Append ID to Name", "Appends a nummerical ID to the end of the name"), appendIDToName.target);
                if (EditorGUILayout.BeginFadeGroup(appendIDToName.faded))
                {
                    EditorGUI.indentLevel++;

                    characterID = EditorGUILayout.IntField("Character ID", characterID);

                    EditorGUI.indentLevel--;
                    DrawHorizontalUILine(Color.gray, 1, 4, 45);
                }
                EditorGUILayout.EndFadeGroup();
            }

            shouldUseFieldOfView.target = EditorGUILayout.ToggleLeft("Use Field Of View", shouldUseFieldOfView.target);
            if (EditorGUILayout.BeginFadeGroup(shouldUseFieldOfView.faded))
            {
                EditorGUI.indentLevel++;

                fieldOfViewMat = EditorGUILayout.ObjectField("Material for the FOW", fieldOfViewMat, typeof(Material), false) as Material;

                obstacleLayer = EditorGUILayout.LayerField(new GUIContent("Obstacle layer", "Sets the layer for obstacles for the FOW"), obstacleLayer);
                targetLayer   = EditorGUILayout.LayerField(new GUIContent("Target layer", "Sets the layer for targets for the FOW"), targetLayer);

                fieldOfViewRadius = EditorGUILayout.IntField(new GUIContent("Field of view radius", "The radius of the field of view"), fieldOfViewRadius);
                if (fieldOfViewRadius < 0)
                {
                    fieldOfViewRadius = 0;
                }
                fieldOfViewAngle = EditorGUILayout.IntSlider(new GUIContent("Field of view angle", "The angle of the field of view"), fieldOfViewAngle, 0, 360);

                EditorGUI.indentLevel--;
            }
            EditorGUILayout.EndFadeGroup();


            EditorGUI.indentLevel--;
        }
        // ---


        DrawHorizontalUILine(Color.gray);
        // --- ---

        EditorGUILayout.Space();

        // --- Object centered basic information ---
        GUILayout.Label("Basic Object information", boldText);
        //GUILayout.Box("FOO", GUILayout.ExpandWidth(true));

        characterModel = EditorGUILayout.ObjectField("Character Model:", characterModel, typeof(GameObject), true) as GameObject;

        // --- Advanced object info ---
        advancedObjectInfo = EditorGUILayout.Foldout(advancedObjectInfo, "Advanced object info", true);
        if (advancedObjectInfo)
        {
            EditorGUI.indentLevel++;

            if (createOrModify != CreateOrModify.modify)
            {
                modelUsesEmptyParent = EditorGUILayout.ToggleLeft(new GUIContent("Model uses empty parent", "Will not child the model to an empty Game Object"), modelUsesEmptyParent);

                useSpecifiedParent.target = EditorGUILayout.ToggleLeft(new GUIContent("Use specified parent object", "will use specified Game Object as parent"), useSpecifiedParent.target);
                if (EditorGUILayout.BeginFadeGroup(useSpecifiedParent.faded))
                {
                    specifiedParent = EditorGUILayout.ObjectField(new GUIContent("Parent Object", "This needs to be a scene object"), specifiedParent, typeof(Transform), true) as Transform;
                }
                else
                {
                    specifiedParent = null;
                }
                EditorGUILayout.EndFadeGroup();
            }

            useSpecifiedTransformForHands.target = EditorGUILayout.ToggleLeft(new GUIContent("Use specified transform for hands"), useSpecifiedTransformForHands.target);
            if (EditorGUILayout.BeginFadeGroup(useSpecifiedTransformForHands.faded))
            {
                mainHand = EditorGUILayout.ObjectField(new GUIContent("Main hand transform", "If left empty, the tool will create one at position 0.75,0.75,0"), mainHand, typeof(Transform), true) as Transform;
                offHand  = EditorGUILayout.ObjectField(new GUIContent("Off hand transform", "If left empty, the tool will create one at position -0.75,0.75,0"), offHand, typeof(Transform), true) as Transform;
            }
            EditorGUILayout.EndFadeGroup();
            if (useSpecifiedTransformForHands.value == false)
            {
                usesNameForFindingHands.target = true;
            }
            else
            {
                usesNameForFindingHands.target = false;
            }
            if (EditorGUILayout.BeginFadeGroup(usesNameForFindingHands.faded))
            {
                mainHandName = EditorGUILayout.TextField(new GUIContent("Main hand name in model", "If left empty, or object cannot be found, the tool will create one at position 0.75,0.75,0"), mainHandName);
                offHandName  = EditorGUILayout.TextField(new GUIContent("Off hand name in model", "if left empty, or object cannot be found, the tool will create one at position -0.75,0.75,0"), offHandName);
            }
            EditorGUILayout.EndFadeGroup();

            attackPoint = EditorGUILayout.ObjectField(new GUIContent("Attack point", "This is the point where an attack is calculated around. It is implemented because of the way the system currently works. If left empty, the tool will create one at position 0,1,2"), attackPoint, typeof(Transform), true) as Transform;


            //CreateFadeGroup<Transform>(useSpecifiedParent, "Use specified parent object", specifiedParent, "parent object");



            EditorGUI.indentLevel--;
        }
        // ---

        DrawHorizontalUILine(Color.gray);

        EditorGUILayout.Space();
        // --- ---

        // --- Do you want a prefab with that? ---
        if (createOrModify != CreateOrModify.modify)
        {
            GUILayout.Label("Prefab information", boldText);
            createPrefab.target = EditorGUILayout.ToggleLeft("Save as a Prefab", createPrefab.target);
            if (EditorGUILayout.BeginFadeGroup(createPrefab.faded))
            {
                EditorGUI.indentLevel++;

                prefabPath     = EditorGUILayout.TextField("Prefab Path", prefabPath == string.Empty ? "'Assets/SomeFolder...'" : prefabPath);
                doCreatePrefab = true;
                keepInScene    = EditorGUILayout.ToggleLeft("Keep in scene?", keepInScene);

                EditorGUI.indentLevel--;
            }
            else
            {
                doCreatePrefab = false;
                keepInScene    = false;
            }
            EditorGUILayout.EndFadeGroup();

            DrawHorizontalUILine(Color.gray);

            EditorGUILayout.Space();
        }
        // --- ---

        // --- Animation stuff ---
        GUILayout.Label("Animator information", boldText);

        animator = EditorGUILayout.ObjectField(new GUIContent("Animator controller"), animator, typeof(RuntimeAnimatorController), false) as RuntimeAnimatorController;
        //animator = EditorGUILayout.PropertyField(new GUIContent("Animator goes here"), animator, typeof(RuntimeAnimatorController)) as RuntimeAnimatorController;
        //EditorGUILayout.fiel
        // --- ---



        // --- Creation/Modification button ---
        if (createOrModify == CreateOrModify.create)
        {
            EditorGUI.BeginDisabledGroup(createButtonDisableParams());

            if (GUILayout.Button("Create Character"))
            {
                CreateCharacter();
            }
            EditorGUI.EndDisabledGroup();
        }
        else
        {
            EditorGUI.BeginDisabledGroup(createButtonDisableParams());

            if (GUILayout.Button("Modify Character"))
            {
                ModifyCharacter();
            }
            EditorGUI.EndDisabledGroup();
        }
        EditorGUILayout.Space();
        // --- ---



        //Stuff for errors here..

        // --- Error messages ---

        // Modify stuff
        if (modifyCharacter.value == true && characterToModify == null)
        {
            EditorGUILayout.HelpBox("Please insert character to modify", MessageType.Warning);
        }
        if (modifyCharacter.value == true && characterToModify != null && characterName == string.Empty)
        {
            EditorGUILayout.HelpBox("Please give a Name to the Character", MessageType.Warning);
        }

        // ---

        // Create stuff


        if (characterName == string.Empty && modifyCharacter.value == false)
        {
            EditorGUILayout.HelpBox("Please give a Name to the Character", MessageType.Warning);
        }

        if (characterModel == null && !modifyCharacter.value == true)
        {
            EditorGUILayout.HelpBox("Please insert Character Model", MessageType.Warning);
        }

        if (playerOrNPC == PlayerOrNPC.NPC && patrolObject == null)
        {
            EditorGUILayout.HelpBox("Please insert a patrol object", MessageType.Warning);
        }

        if (shouldUseFieldOfView.value == true && fieldOfViewMat == null)
        {
            EditorGUILayout.HelpBox("Please supply a material for the field of view", MessageType.Warning);
        }

        if (shouldUseFieldOfView.value == true && obstacleLayer == LayerMask.NameToLayer("Default"))
        {
            EditorGUILayout.HelpBox("Obstacle layer should not be default", MessageType.Warning);
        }

        if (shouldUseFieldOfView.value == true && targetLayer == LayerMask.NameToLayer("Default"))
        {
            EditorGUILayout.HelpBox("Target layer should not be default", MessageType.Warning);
        }

        if (useSpecifiedParent.value == true && specifiedParent == null)
        {
            EditorGUILayout.HelpBox("Please supply a parent object", MessageType.Warning);
        }

        if (useSpecifiedParent.value == true && specifiedParent != null && EditorUtility.IsPersistent(specifiedParent))
        {
            EditorGUILayout.HelpBox("Specified parent object needs to be a scene object", MessageType.Warning);
        }

        if (createPrefab.value == true && prefabPath == "'Assets/SomeFolder...'")
        {
            EditorGUILayout.HelpBox("Please insert a valid path name for your prefab", MessageType.Warning);
        }

        // ---

        // --- ---
    }
Ejemplo n.º 49
0
        public bool Move(ref float x, ref float y, float stepX, float stepY, MovementType movementType, bool hero)
        {
            bool forceSlide = (stepX != 0 && stepY != 0);

            while (stepX != 0 || stepY != 0)
            {
                float step_x = 0;
                if (stepX > 0)
                {
                    step_x = Math.Min((float)Math.Ceiling(x) - x, stepX);
                    if (step_x <= MIN_TILE_GAP)
                    {
                        step_x = Math.Min(1.0f, stepX);
                    }
                }
                else if (stepX < 0)
                {
                    step_x = Math.Max((float)Math.Floor(x) - x, stepX);
                    if (step_x == 0)
                    {
                        step_x = Math.Max(-1.0f, stepX);
                    }
                }
                float step_y = 0;
                if (stepY > 0)
                {
                    step_y = Math.Min((float)Math.Ceiling(y) - y, stepY);
                    if (step_y <= MIN_TILE_GAP)
                    {
                        step_y = Math.Min(1.0f, stepY);
                    }
                }
                else if (stepY < 0)
                {
                    step_y = Math.Max((float)Math.Floor(y) - y, stepY);
                    if (step_y == 0)
                    {
                        step_y = Math.Max(-1.0f, stepY);
                    }
                }
                stepX -= step_x;
                stepY -= step_y;
                if (!SmallStep(ref x, ref y, step_x, step_y, movementType, hero))
                {
                    if (forceSlide)
                    {
                        if (!SmallStepForcedSlideAlongGrid(ref x, ref y, step_x, step_y, movementType, hero))
                        {
                            return(false);
                        }
                    }
                    else
                    {
                        if (!SmallStepForcedSlid(ref x, ref y, step_x, step_y, movementType, hero))
                        {
                            return(false);
                        }
                    }
                }
            }
            return(true);
        }
Ejemplo n.º 50
0
 public EffectMovementType(IEffectHolder holder, MovementType movementType, double priority)
 {
     Holder       = holder;
     MovementType = movementType;
     Priority     = priority;
 }
Ejemplo n.º 51
0
 public override void Accept(INodeVisitor visitor, ITempNode source, MovementType movementType)
 {
     visitor.Visit(source, this, movementType);
 }
Ejemplo n.º 52
0
 public override void ReadJson(JToken json, Context context)
 {
     Holder       = Serializer.GetHolder <IEffectHolder>(json["holder"], context);
     MovementType = MovementType.GetMovementType(json["type"].Value <string>());
     Priority     = json["priority"].Value <double>();
 }
Ejemplo n.º 53
0
 public override void Accept(INodeVisitor visitor, INode target, MovementType movementType)
 {
     target.Accept(visitor, this, movementType);
 }
Ejemplo n.º 54
0
 public Orders(BaseFactionGuard guard)
 {
     m_Guard     = guard;
     m_Reactions = new List <Reaction>();
     m_Movement  = MovementType.Patrol;
 }
Ejemplo n.º 55
0
        public DrawGamePlayerPacket(ObjectId playerId, ModelId bodyType, Location3D location, Direction direction, MovementType movementType, Color color)
        {
            PlayerId = playerId;
            BodyType = bodyType;
            Location = location;
            Color    = color;

            Serialize();
        }
Ejemplo n.º 56
0
 public void Pause()
 {
     SavedMovement = Movement;
     Movement      = MovementType.Paused;
 }
Ejemplo n.º 57
0
        private void DisplayCurrentFrame(MovementType movementType)
        {
            if (m_VideoStream != null)
            {
                if (m_CurrentFrameIndex > m_VideoStream.LastFrame) m_CurrentFrameIndex = m_VideoStream.LastFrame;
                if (m_CurrentFrameIndex < m_VideoStream.FirstFrame) m_CurrentFrameIndex = m_VideoStream.FirstFrame;

                Pixelmap currentBitmap = null;

                if (m_FrameIntegration == FrameIntegratingMode.NoIntegration || !m_VideoStream.SupportsSoftwareIntegration)
                {
                    currentBitmap = m_VideoStream.GetPixelmap(CurrentDirectionAwareFrameIndex);
                }
                else if (m_FrameIntegration == FrameIntegratingMode.SlidingAverage)
                {
                    currentBitmap = ProduceRunningAverageIntegratedFrame(m_CurrentFrameIndex);
                }
                else if (m_FrameIntegration == FrameIntegratingMode.SteppedAverage)
                {
                    currentBitmap = ProduceBinningIntegratedFrame(m_CurrentFrameIndex);
                }
                else
                    throw new NotSupportedException();

                string frameFileName = m_VideoStream.SupportsFrameFileNames ? m_VideoStream.GetFrameFileName(CurrentDirectionAwareFrameIndex) : null;

                DisplayCurrentFrameInternal(movementType, currentBitmap, frameFileName);
            }
        }
Ejemplo n.º 58
0
        public DrawGamePlayerPacket(ObjectId playerId, ModelId bodyType, Location3D location, Direction direction, MovementType movementType, Color color)
        {
            var payload = new byte[19];
            var writer  = new ArrayPacketWriter(payload);

            PlayerId = playerId;
            BodyType = bodyType;
            Location = location;
            Color    = color;

            writer.WriteByte((byte)PacketDefinitions.DrawGamePlayer.Id);
            writer.WriteId(playerId);
            writer.WriteModelId(bodyType);
            writer.WriteByte(0); // unknown
            writer.WriteColor(color);
            writer.WriteByte(0); // flag, alway 0
            writer.WriteUShort((ushort)location.X);
            writer.WriteUShort((ushort)location.Y);
            writer.WriteUShort(0); // unknown
            writer.WriteMovement(direction, movementType);
            writer.WriteSByte((sbyte)location.Z);

            rawPacket = new Packet(PacketDefinitions.DrawGamePlayer.Id, payload);
        }
Ejemplo n.º 59
0
        private void DisplayCurrentFrameNoIntegrate(MovementType movementType)
        {
            if (m_VideoStream != null)
            {
                Pixelmap currentBitmap = m_VideoStream.GetPixelmap(CurrentDirectionAwareFrameIndex);
                string frameFileName = m_VideoStream.SupportsFrameFileNames ? m_VideoStream.GetFrameFileName(CurrentDirectionAwareFrameIndex) : null;

                DisplayCurrentFrameInternal(movementType, currentBitmap, frameFileName);
            }
        }
Ejemplo n.º 60
0
 private void PlayerMoveServer(Vector3 destination, MovementType movementType)
 {
     new MovePlayerBuilder(socket, this, socket.sid, destination, (int)movementType);
 }