next() public static méthode

public static next ( Entity, entity ) : Cell,
entity Entity,
Résultat Cell,
Exemple #1
0
    public void removePaint(Cell cell, Skill skill, Entity entity = null)
    {
        Vector2 position = cell.Map.getCoords(cell.gameObject);
        int     contador = 0;
        float   xcentral = position.x;
        float   ycentral = position.y;

        //busqueda directa
        //Vamos a marcar todas las casillas que esten en la distancia de la habilidad
        for (float i = position.x - skill.getDistance(); i <= position.x + skill.getDistance(); i++)
        {
            //vamos aumentando el radio de casillas hasta la distancia de la habilidad
            for (float j = position.y - skill.getDistance(); j <= position.y + skill.getDistance(); j++)
            {
                Cell celdaAPintar = cell.Map.getCell(new Vector2(i, j));

                if (celdaAPintar != null)
                {
                    if (entity != null)
                    {
                        if (RoutePlanifier.planifyRoute(entity.mover, celdaAPintar))
                        {
                            int  distance = 0;
                            Cell measuring;
                            while (distance <= skill.getDistance() && (measuring = RoutePlanifier.next(entity.mover)))
                            {
                                entity.Position = measuring;
                                distance++;
                            }
                            entity.Position = cell;

                            RoutePlanifier.cancelRoute(entity.mover);

                            if (distance > skill.getDistance())
                            {
                                continue;
                            }
                        }
                        else
                        {
                            continue;
                        }
                    }

                    if ((int)Mathf.Abs(Mathf.Abs(i - xcentral) + Mathf.Abs(j - ycentral)) <= skill.getDistance())
                    {
                        if (contador < oldTextures.Length && oldTextures[contador] != null)
                        {
                            celdaAPintar.Properties.faces[celdaAPintar.Properties.faces.Length - 1].TextureMapping = oldTextures[contador];
                            celdaAPintar.Properties.faces[celdaAPintar.Properties.faces.Length - 1].Texture        = oldTextures[contador].getTexture();
                            celdaAPintar.forceRefresh();
                        }
                        contador++;
                    }
                }
            }
        }
    }
Exemple #2
0
    public override void Update()
    {
        if (this.dec == null)
        {
            this.dec = Entity.decoration;
        }

        // Force initial direction update
        if (this.movement == null)
        {
            movement = createTurnMovement(direction);
            movement.addProgress(1f); // Move to End
            movement.Update();        // Assure finalization
            movement.UpdateTextures();
        }

        // If we're not moving right now
        if (!IsMoving)
        {
            // Let's see if we have something to do...
            next = RoutePlanifier.next(this);
            //Then, let's move :D
            if (next != null)
            {
                Vector3 myPosition    = this.Entity.Position.transform.localPosition,
                        otherPosition = next.transform.localPosition;

                // Define the movement type and set the tilesheet
                MovementType type = getMovementTypeTo(next);
                this.movement = Movement.createMovement(type,                                                                                         // type
                                                        this.Entity,                                                                                  // Entity
                                                        this,                                                                                         // Mover
                                                        dec,                                                                                          // Decoration
                                                        getSpritesheetForMovementType(type),                                                          // Sheet
                                                        transform.position,                                                                           // Origin
                                                        next.transform.position + new Vector3(0, next.WalkingHeight + transform.localScale.y / 2, 0), // Destination
                                                        Entity.Position,                                                                              // Cell Origin
                                                        next,                                                                                         // Cell Destination
                                                        null);                                                                                        // Extra Params
            }
            else if (movementEvent != null)
            {
                movementFinished = true;
                if (turnAfterMove)
                {
                    switchDirection(turnDirection);
                    turnAfterMove = false;
                }
            }
        }

        if (IsMoving)
        {
            // Update the progress
            this.movement.Update();
            this.movement.UpdateTextures();
            // If the movement has ended
            if (this.movement.Ended)
            {
                paso = !paso;
            }
        }
    }
Exemple #3
0
    public override void Update()
    {
        this.dec = Entity.decoration;
        if (!isMoving)
        {
            next = RoutePlanifier.next(this.Entity);
            if (next != null)
            {
                Vector3 myPosition    = this.Entity.Position.transform.localPosition,
                        otherPosition = next.transform.localPosition;

                MovementType type = MovementType.Lineal;
                if (Entity.Position.WalkingHeight != next.WalkingHeight)
                {
                    type       = MovementType.Parabolic;
                    dec.IsoDec = jumpingSprite;
                }
                dec.updateTextures();
                int row = 0;
                if (myPosition.z < otherPosition.z)
                {
                    row = 0;
                }
                else if (myPosition.z > otherPosition.z)
                {
                    row = 2;
                }
                else if (myPosition.x < otherPosition.x)
                {
                    row = 1;
                }
                else if (myPosition.x > otherPosition.x)
                {
                    row = 3;
                }
                dec.Tile = tile = row * dec.IsoDec.nCols;

                this.movement         = Movement.createMovement(type, transform.position, next.transform.position + new Vector3(0, next.WalkingHeight + transform.localScale.y / 2, 0));
                this.movementProgress = 0;
                this.movementDuration = 0.3f;
                isMoving = true;
            }
            else if (movementEvent != null)
            {
                movementFinished = true;
            }
        }

        if (isMoving)
        {
            this.movementProgress += Time.deltaTime;
            transform.position     = this.movement.getPositionAt(this.movementProgress / this.movementDuration);


            if (dec.IsoDec.nCols > 1)
            {
                if (this.movementProgress / this.movementDuration < 0.15)
                {
                    dec.Tile = tile;
                }
                else if (this.movementProgress / this.movementDuration < 0.85)
                {
                    dec.Tile = tile + ((paso)?1:2);
                }
                else if (this.movementProgress / this.movementDuration < 1)
                {
                    dec.Tile = tile;
                }
            }


            if (this.movementProgress >= this.movementDuration)
            {
                this.isMoving        = false;
                this.Entity.Position = next;
                int lastRow = Mathf.FloorToInt(tile / dec.IsoDec.nCols);
                dec.IsoDec = normalSprite;
                dec.updateTextures();
                dec.Tile = lastRow * dec.IsoDec.nCols;
                paso     = !paso;
            }
        }
    }
Exemple #4
0
    public override void Update()
    {
        this.dec = Entity.decoration;
        if (!isMoving)
        {
            next = RoutePlanifier.next(this.Entity);
            if (next != null)
            {
                //Evento de perder energia
                if (decreaseEnergy != 0)
                {
                    GameEvent ge = ScriptableObject.CreateInstance <GameEvent>();
                    ge.setParameter("entity", this.Entity);
                    ge.setParameter("energia", decreaseEnergy);
                    ge.Name = "modify energia";

                    Game.main.enqueueEvent(ge);
                }

                Vector3 myPosition    = ((Cell)this.Entity.Position).transform.localPosition,
                        otherPosition = next.transform.localPosition;

                MovementType type = MovementType.Lineal;
                if (((Cell)this.Entity.Position).WalkingHeight != next.WalkingHeight)
                {
                    type       = MovementType.Parabolic;
                    dec.IsoDec = jumpingSprite;
                }
                dec.updateTextures();
                int row = 0;
                if (myPosition.z < otherPosition.z)
                {
                    row = 0;
                }
                else if (myPosition.z > otherPosition.z)
                {
                    row = 2;
                }
                else if (myPosition.x < otherPosition.x)
                {
                    row = 1;
                }
                else if (myPosition.x > otherPosition.x)
                {
                    row = 3;
                }
                dec.Tile = tile = row * dec.IsoDec.nCols;

                this.movement         = Movement.createMovement(type, transform.position, next.transform.position + new Vector3(0, next.WalkingHeight + transform.localScale.y / 2, 0));
                this.movementProgress = 0;
                this.movementDuration = 0.3f;
                isMoving = true;
            }
            else if (movementEvent != null)
            {
                movementFinished = true;
            }
        }

        if (isMoving)
        {
            this.movementProgress += Time.deltaTime;
            transform.position     = this.movement.getPositionAt(this.movementProgress / this.movementDuration);


            if (dec.IsoDec.nCols > 1)
            {
                if (this.movementProgress / this.movementDuration < 0.15)
                {
                    dec.Tile = tile;
                }
                else if (this.movementProgress / this.movementDuration < 0.85)
                {
                    dec.Tile = tile + ((paso) ? 1 : 2);
                }
                else if (this.movementProgress / this.movementDuration < 1)
                {
                    dec.Tile = tile;
                }
            }


            if (this.movementProgress >= this.movementDuration)
            {
                this.isMoving        = false;
                this.Entity.Position = next;
                int lastRow = Mathf.FloorToInt(tile / dec.IsoDec.nCols);
                dec.IsoDec = normalSprite;
                dec.updateTextures();
                dec.Tile = lastRow * dec.IsoDec.nCols;
                paso     = !paso;
            }
        }
    }