Example #1
0
 /// <summary>
 /// Returns a list of pirates that are within attack range of "loc", and their state is "state"
 /// </summary>
 public List <Pirate> GetPiratesInAttackRange(ILocateable loc, PirateState state)
 {
     if (!this.map.InMap(loc))
     {
         return(null);
     }
     return(new List <Pirate>(this.attackRangeMap[loc.GetLocation().Row, loc.GetLocation().Collumn, (int)state]));
 }
    public void VibrationDetected(Vector3 vibrationPosition)
    {
        this.vibrationPosition = vibrationPosition;

        currentState = PirateState.inspect;

        transform.LookAt(vibrationPosition);
    }
Example #3
0
        /// <summary>
        /// Returns wether there are pirates whose state is "state", that are in attack range of "loc"
        /// </summary>
        public bool HasPiratesInAttackRange(ILocateable loc, PirateState state)
        {
            if (!this.map.InMap(loc))
            {
                return(false);
            }

            return(this.attackRangeMap[loc.GetLocation().Row, loc.GetLocation().Collumn, (int)state].Count > 0);
        }
    protected void Inspect()
    {
        inspectCountdown -= Time.deltaTime;

        if (inspectCountdown <= 0f)
        {
            currentState = PirateState.patrol;
        }
    }
    protected void Evacuate()
    {
        if (pirateRigidbody.position == patrolCenter)
        {
            //Destroy(gameObject);
            currentState = PirateState.patrol;
            return;
        }

        pirateRigidbody.position = Vector3.MoveTowards(transform.position, patrolCenter, speed * evacSpeedMultiplier * Time.deltaTime);
    }
    protected void DetectPlayer()
    {
        Collider[] playerCollideCheck = Physics.OverlapSphere(transform.position, playerDetectionRadius, Global.layer_Player);

        if (playerCollideCheck.Length > 0)
        {
            currentState = PirateState.chase;

            moveToPosition = Vector3.zero;
            pirateRigidbody.angularVelocity = Vector3.zero;

            playerPosition = playerCollideCheck[0].gameObject.GetComponent <Transform>().position;
        }
        else if (playerPosition != Vector3.zero)
        {
            playerPosition = Vector3.zero;
        }
    }
Example #7
0
 public void MakeTransition(PirateState state)
 {
     Debug.Log(state);
     currentState = states[state];
     currentState.StartState();
 }
Example #8
0
 public static List <Pirate> PiratesWithState(PirateState state) => game.GetAllMyPirates().Where(p => p.StateName == state.ToString()).ToList();
Example #9
0
        /// <summary>
        /// Updates this pirate
        /// </summary>
        public void Update(Pirates.Pirate p)
        {
            this.nativeObject = p;

            // updates the pirate's state
            if (p.IsLost)
            {
                this.state = PirateState.Lost;
            }
            else if (p.TurnsToSober > 0)
            {
                this.state = PirateState.Drunk;
            }
            else if (p.HasTreasure)
            {
                this.state = PirateState.CarryingTreasure;
            }
            else
            {
                this.state = PirateState.Free;
            }

            // updates the pirate's location, but ONLY if the new location can possibly be inside the map
            if (p.Location != null && p.Location.Row >= 0 && p.Location.Col >= 0)
            {
                this.location = new Location(p.Location);
            }

            // updates counters
            this.turnsToSober         = p.TurnsToSober;
            this.turnsToRevive        = p.TurnsToRevive;
            this.turnsToAttackReload  = p.ReloadTurns;
            this.turnsToDefenseReload = p.DefenseReloadTurns;
            this.defenseDuration      = p.DefenseExpirationTurns;

            // updates carried treasure; should be updated to not-null manually every turn
            this.carriedTreasure = null;

            // updates powerups
            if (p.Powerups != null)
            {
                this.powerups = new List <string>(p.Powerups);
            }
            else
            {
                this.powerups = new List <string>();
            }

            // calculate current speed limit
            if (this.State == PirateState.CarryingTreasure)
            {
                this.maxSpeed = p.CarryTreasureSpeed;
            }
            else
            {
                this.maxSpeed = this.freePirateMaxSpeed;
            }

            // calculate attack radius
            this.attackRadius = Utils.Pow(p.AttackRadius, 0.5);
        }
Example #10
0
 /// <summary>
 /// Returns a list of the enemy pirates that are within attack range of "loc", and their state is "state"
 /// </summary>
 public List <Pirate> GetEnemyPiratesInAttackRange(ILocateable loc, PirateState state)
 {
     return(this.map.EnemyAttackMap.GetPiratesInAttackRange(loc, state));
 }