コード例 #1
0
 void Awake()
 {
     if (instance == null)
     {
         instance = this;
     }
 }
コード例 #2
0
ファイル: AIControl.cs プロジェクト: point01/Square-Wars
    public static void moveTowardsUnit(UnitActions target)
    {
        int currentDist = 9999;
        List<Tile> MoveTiles = Movement.GetMovement(GameManager.CurrentTurnPlayer);
        Tile ldestTile = null;

        // Check distance between movementTiles and enemy to get the closest tile.
        /*foreach (UnitActions p in GameManager.enemyTeam.myRoster)
        {
            foreach (Tile t in MoveTiles)
            {
                int tempDist = Movement.GetDistance(Movement.GetTileFromPlayer(p), t);
                //TODO add condition to check if tile is full or not
                if (tempDist < currentDist)
                {
                    currentDist = tempDist;
                    ldestTile = t;
                }

            }
        }*/
        //previous code doesn't actually use the target?
        foreach (Tile t in MoveTiles)
        {
            int tempDist = Movement.GetDistance(Movement.GetTileFromPlayer(target), t);
            if (tempDist < currentDist)
            {
                currentDist = tempDist;
                ldestTile = t;
            }
        }
        GameManager.moveCurrentPlayer(ldestTile);
    }
コード例 #3
0
ファイル: GameManager.cs プロジェクト: pablolluchr/genetica
 public void DeselectUnit()
 {
     unitInfoPanel.Hide();
     UnitActions.DisableSelectionGraphic(selectedUnit);
     //UnitActions.DisableAllSelectionGraphics();
     selectedUnit = null;
 }
コード例 #4
0
ファイル: Unit.cs プロジェクト: pablolluchr/genetica
    private void Update()
    {
        if (dead)
        {
            return;
        }
        if (gameObject.CompareTag("Preview"))
        {
            return;
        }

        UnitActions.Move(this);
        UpdateMovingAnimation();
        UnitActions.UpdateIsSwimming(this);

        updateCounter = (updateCounter + 1) % GameManager.gameManager.countsBetweenUpdates;
        if (updateCounter == 0)
        {
            UnitActions.SetThought(this);
            //UnitActions.WanderIfDeadTarget(this);
            UnitActions.HungerEffect(this);
            UnitActions.ThirstEffect(this);
            UnitActions.TurnHungryChance(this);
            UnitActions.TurnThirstyChance(this);
            UnitActions.TurnHornyChance(this);
            UnitActions.HealthRegenEffect(this);
            unitState = UnitStateMachine.NextState(this);
        }
    }
コード例 #5
0
ファイル: Brain.cs プロジェクト: AndreyMartunyk/TestGame
        private UnitActions Bullet(GameObject bullet, Direction dir)
        {
            UnitActions bulletAction = UnitActions.None;

            switch (dir)
            {
            case Direction.None:
                bulletAction = bullet.Action;
                break;

            case Direction.Top:
                bulletAction = UnitActions.MoveTop;
                break;

            case Direction.Down:
                bulletAction = UnitActions.MoveDown;
                break;

            case Direction.Left:
                bulletAction = UnitActions.MoveLeft;
                break;

            case Direction.Right:
                bulletAction = UnitActions.MoveRight;
                break;

            default:
                break;
            }

            return(bulletAction);
        }
コード例 #6
0
ファイル: Species.cs プロジェクト: pablolluchr/genetica
    public GameObject Spawn()
    {
        Vector3    spawnPosition = foodSource.transform.position + Random.onUnitSphere * 2f;
        GameObject unit          = MonoBehaviour.Instantiate(unitPrefab, spawnPosition, unitPrefab.transform.rotation);

        unit.transform.parent = GameManager.gameManager.units.transform;
        Unit unitComponent = unit.GetComponent <Unit>();

        unitComponent.speciesName = speciesName;
        UpdateUnit(unitComponent);
        UnitActions.DisableSelectionGraphic(unitComponent);

        //if (unitComponent.CompareTag("Preview"))
        //    GameManager.gameManager.previewUnitList.Add(unitComponent);
        if (unitComponent.CompareTag("Pet"))
        {
            GameManager.gameManager.petList.Add(unitComponent);
        }
        else if (unitComponent.CompareTag("Hostile"))
        {
            GameManager.gameManager.enemyList.Add(unitComponent);
        }

        return(unit);
    }
コード例 #7
0
ファイル: GameObject.cs プロジェクト: AndreyMartunyk/TestGame
        private UnitActions ShootDirAction(Direction dir)
        {
            UnitActions action = UnitActions.None;

            switch (dir)
            {
            case Direction.None:
                break;

            case Direction.Top:
                action = UnitActions.MoveTop;
                break;

            case Direction.Down:
                action = UnitActions.MoveDown;
                break;

            case Direction.Left:
                action = UnitActions.MoveLeft;
                break;

            case Direction.Right:
                action = UnitActions.MoveRight;
                break;

            default:
                break;
            }

            return(action);
        }
コード例 #8
0
 public static void SelectAllUnitsOfSpecies(Species species)
 {
     List<Unit> units = species.GetAllUnitsOfSpecies();
     foreach (Unit unit in units)
     {
         UnitActions.EnableSelectionGraphic(unit);
     }
 }
コード例 #9
0
 public static void Attack(Unit unit) {
     if (Time.time - unit.lastAttacked < unit.attackRate) return;
     unit.lastAttacked = Time.time;
     //if (unit.GetComponent<Target>().targetGameObject == null) return;
     Unit enemy = unit.GetComponent<Target>().targetGameObject.GetComponent<Unit>();
     UnitActions.TakeDamage(enemy, unit.attackDamage);
     //todo:attack animation (simulate force)
 }
コード例 #10
0
ファイル: GameManager.cs プロジェクト: pablolluchr/genetica
 public void SelectUnit()
 {
     forcePanelExit = false;
     cameraController.StartFollowing(clickedObject.transform, "in");
     selectedUnit = clickedObject.GetComponent <Unit>();
     UnitActions.EnableSelectionGraphic(selectedUnit);
     unitInfoPanel.Show(selectedUnit);
 }
コード例 #11
0
 void Awake()
 {
     cam = transform.GetChild(1).gameObject.GetComponent <Camera>();
     lastMousePosition = Input.mousePosition;
     player            = transform.GetChild(0);
     unitActions       = GetComponent <UnitActions>();
     MouseRotation();
 }
コード例 #12
0
ファイル: GameManager.cs プロジェクト: pablolluchr/genetica
    public void OverrideSelectedSpeciesUnitTargets()
    {
        List <Unit> unitsofSpecies = selectedSpecies.GetAllUnitsOfSpecies();

        foreach (var unit in unitsofSpecies)
        {
            UnitActions.OverrideTarget(unit, clickedPoint);
        }
    }
コード例 #13
0
    //Unit behaviour functions that change values of the unit

    #region hunger // ##################################################################################
    
    public static void HungerEffect(Unit unit) {
        if (unit.amountFed <= 0) {
            UnitActions.TakeDamage(unit, unit.hungerDamage *
                Time.deltaTime * GameManager.gameManager.countsBetweenUpdates);
            unit.amountFed = 0;
        } else {
            unit.amountFed -= unit.hungerPerSecond *
                Time.deltaTime * GameManager.gameManager.countsBetweenUpdates;
        }
    }
コード例 #14
0
 public static void ThirstEffect(Unit unit) {
     if (unit.amountQuenched <= 0) {
         UnitActions.TakeDamage(unit, unit.thirstDamage *
             Time.deltaTime * GameManager.gameManager.countsBetweenUpdates);
         unit.amountQuenched = 0;
     } else {
         unit.amountQuenched -= unit.thirstPerSecond *
             Time.deltaTime * GameManager.gameManager.countsBetweenUpdates;
     }
 }
コード例 #15
0
ファイル: GameManager.cs プロジェクト: pablolluchr/genetica
 public void SelectSpecies()
 {
     //todo: maybe move camera to the units average point instead?
     forcePanelExit = false;
     speciesInfoPanel.Show(selectedSpecies);
     UnitActions.SelectAllUnitsOfSpecies(selectedSpecies);
     ShowSpeciesLightbeams();
     cameraController.StartFollowing(selectedSpecies.foodSource.transform, "out");
     newSpeciesSelected = false;
 }
コード例 #16
0
        public GameObject PlayerBullet(Coordinate coord, int shooterDamage, UnitActions action)
        {
            GameObject bullet = DefaultBullet(coord);

            bullet.Damage   = shooterDamage;
            bullet.HP       = 999;
            bullet.Ui.Color = GameColors.Cyan;
            bullet.Action   = action;

            return(bullet);
        }
コード例 #17
0
ファイル: GameManager.cs プロジェクト: pablolluchr/genetica
    public void DeselectSpecies()
    {
        UnitActions.DisableAllSelectionGraphics();
        HideSpeciesLightbeams();
        //SetTargetsToNull();
        FreePan();

        cameraController.zoomType = "in";
        speciesInfoPanel.Hide();
        selectedSpecies = null;
    }
コード例 #18
0
    public static bool RequiresTarget(this UnitActions action)
    {
        UnitActions[] actionsThatRequireTargets = new UnitActions[]
        {
            UnitActions.Attack,
            UnitActions.Heal,
            UnitActions.StrongAttack
        };

        return(actionsThatRequireTargets.Contains(action));
    }
コード例 #19
0
ファイル: Species.cs プロジェクト: pablolluchr/genetica
    public void UpdateUnit(Unit unit)   //returns true if succeeds, false otherwise
    //if (unit.speciesName != speciesName) { return; } //cant modify another species

    {
        if (!unit.CompareTag("Hostile"))
        {
            unit.UpdateHeadSize(headSize);
            unit.UpdateLegSize(legSize);
            unit.UpdateBellySize(bellySize);
            unit.UpdateEarSize(earSize);
            unit.UpdateTailSize(tailSize);
            unit.UpdateArmSize(armSize);
            unit.UpdateFurColor(color);
        }

        if (unit.CompareTag("Preview"))
        {
            return;
        }

        unit.genetiumSource    = genetiumSource;
        unit.foodSource        = foodSource;
        unit.speed             = speed;
        unit.interactionRadius = UnitHelperFunctions.Interpolate(legSize, new float[, ] {
            { 0.2f, 0.5f }, { 0.6f, 0.6f }
        });                                                                                                          //todo: rethink this

        //unit.areaCenter = areaCenter;


        //unit.areaRadius = AreaRadiusFromSize();
        unit.gameObject.tag = tag;
        unit.swimspeed      = swimspeed;

        if (tag == "Pet")
        {
            unit.enemyTag = "Hostile";
        }
        else if (tag == "Hostile")
        {
            unit.enemyTag = "Pet";
        }
        else
        {
            throw new System.Exception("Wrong tag for unit");
        }
        UnitActions.ResetSelectionGraphicPosition(unit);
        return;
    }
コード例 #20
0
 public void CallAction_Move()
 {
     if (HeldObject != null)
     {
         if (HeldObject.GetComponent <UnitActions>() == true)
         {
             UnitActions actions = HeldObject.GetComponent <UnitActions>();
             if (actions.ActionAvailable && actions.ActionsMove)
             {
                 Debug.Log("MOVING!!!");
                 actions.MoveChecking = true;
             }
         }
     }
 }
コード例 #21
0
 /// <summary>
 /// Hides all the gui forms that can be hidden
 /// </summary>
 /// <param name="hideCityManagment"></param>
 /// <param name="hideUnitActions"></param>
 public void HideForms(bool hideCityManagment = true, bool hideUnitActions = true)
 {
     CityList.Hide();
     UnitList.Hide();
     if (hideUnitActions)
     {
         UnitActions.Hide();
     }
     if (hideCityManagment)
     {
         CityManagment.Hide();
     }
     TechTree.Hide();
     SocialPolicy.Hide();
 }
コード例 #22
0
    private void Awake()
    {
        actions     = GetComponent <UnitActions>();
        health      = GetComponent <UnitHealth>();
        nextFire    = Time.time + fireRate + Random.Range(0.25f, 2f);
        playerUnits = new List <GameObject>();

        Transform playerTransform = GameObject.FindGameObjectWithTag("Player").transform;
        int       count           = playerTransform.childCount;

        for (int i = 0; i < count; ++i)
        {
            playerUnits.Add(playerTransform.GetChild(i).gameObject);
        }
    }
コード例 #23
0
ファイル: Unit.cs プロジェクト: bjck/AMFU
    public void UseTurn(UnitActions action, object value)
    {
        if (_leftMoves > 0 || _moving || _attacking)
        {
            //TODO Do an action
            switch (action)
            {
            case UnitActions.Move:
                if (!_moving)
                {
                    Attacking       = false;
                    _leftMoveLength = _maxMoveLength;
                    Moving          = true;
                }
                _leftMoves--;
                break;

            case UnitActions.Attack:
                if (!_attacking)
                {
                    Moving    = false;
                    Attacking = true;

                    _attackRangeEmitter.transform.localScale = new Vector3(_attackRange * 2, 0.1f, _attackRange * 2);
                }
                _leftMoves--;
                break;

            case UnitActions.Heal:
                if (_leftHealthPacks > 0)
                {
                    Heal();
                    _leftHealthPacks--;
                    _leftMoves--;
                }
                break;

            case UnitActions.Guard:
                _guarding = true;
                break;
            }
        }
        else
        {
            Debug.Log("Don't have any moves left");
            //Can't do anymore this turn.
        }
    }
コード例 #24
0
 public void CallAction_Sync()
 {
     if (HeldObject != null)
     {
         if (HeldObject.GetComponent <UnitActions>() == true)
         {
             UnitActions actions = HeldObject.GetComponent <UnitActions>();
             if (actions.ActionAvailable)
             {
                 Debug.Log("SYNCHRONISING!!! Does nothing");
                 actions.Action_Synch();
                 Cancel();
             }
         }
     }
 }
コード例 #25
0
 public void CallAction_Wait()
 {
     if (HeldObject != null)
     {
         if (HeldObject.GetComponent <UnitActions>() == true)
         {
             UnitActions actions = HeldObject.GetComponent <UnitActions>();
             if (actions.ActionAvailable)
             {
                 Debug.Log("WAITING!!!");
                 actions.Action_Wait();
                 Cancel();
             }
         }
     }
 }
コード例 #26
0
ファイル: UnitActions.cs プロジェクト: point01/Square-Wars
    /**************************************************************************************************************************
     * This method calculates the damage of a potential attack. Can be used for unitCombat method, the UI, and the log.
     *
     * @attacker The attacking unit. Can be either the User's unit or the Enemy (other user or AI).
     * @defender The unit that didn't start the attack. Can be either the User's unit or the Enemy (other user or AI).
     *
     *************************************************************************************************************************/
    //Once environment tiles and abilities are done, this will be more complex
    public int attackDamage(UnitActions attacker, UnitActions defender)
    {
        int damage;

        if (attacker.unitClass != null && attacker.unitClass.Equals("Mage"))
        {
            damage = attacker.unitMAG - defender.unitMDF;
        }

        else
        {
            damage = attacker.unitSTR - defender.unitDEF;
        }

        return damage;
    }
コード例 #27
0
 public void CallAction_Attack()
 {
     if (HeldObject != null)
     {
         if (HeldObject.GetComponent <UnitActions>() == true)
         {
             UnitActions actions = HeldObject.GetComponent <UnitActions>();
             if (actions.ActionAvailable)
             {
                 Debug.Log("ATTACKING!!!");
                 actions.Action_Attack();
                 //Cancel();
             }
         }
     }
 }
コード例 #28
0
        public UnitActions GetActionFromKey(ConsoleKey key)
        {
            UnitActions action = UnitActions.None;

            switch (key)
            {
            case ConsoleKey.A:
                action = UnitActions.MoveLeft;
                break;

            case ConsoleKey.D:
                action = UnitActions.MoveRight;
                break;

            case ConsoleKey.W:
                action = UnitActions.MoveTop;
                break;

            case ConsoleKey.S:
                action = UnitActions.MoveDown;
                break;

            case ConsoleKey.LeftArrow:
                action = UnitActions.ShootLeft;
                break;

            case ConsoleKey.RightArrow:
                action = UnitActions.ShootRight;
                break;

            case ConsoleKey.UpArrow:
                action = UnitActions.ShootUp;
                break;

            case ConsoleKey.DownArrow:
                action = UnitActions.ShootDown;
                break;

            default:
                //никак не реагируем при нажатиии незадекларируемой клавиши
                break;
            }

            return(action);
        }
コード例 #29
0
    // Use this for initialization
    void Start()
    {
        actions = GetComponent <UnitActions>();
        if (actions == null)
        {
            Debug.LogError("actions is null in complexactions");
        }

        sensor = GetComponent <UnitSensor>();
        if (sensor == null)
        {
            Debug.LogError("sensor is null in complexactions");
        }

        path           = new NavMeshPath();
        relativeHeight = new Vector3(0, transform.position.y, 0);
        if (relativeHeight.y > 1.6)
        {
            Debug.Log("make sure to spawn agent right above ground");
        }

        stuckIteration       = -1;
        obstaclesCheckExtend = new Vector3(0.2f, transform.position.y, 1f);
        lastJumpTime         = Time.timeSinceLevelLoad;
        lastStuckIncrement   = Time.realtimeSinceStartup;
        agentLayer           = LayerMask.GetMask("Agent");
        physicalLayer        = LayerMask.GetMask("PickupAble");


        if (sensor.rightStartWeapon != null)
        {
            Physics.IgnoreCollision(GetComponent <CapsuleCollider>(), sensor.rightStartWeapon.GetComponent <Collider>());
            actions.PickupObject(sensor.rightStartWeapon, sensor.rightHand, sensor.rightWeaponPos);
        }
        if (sensor.leftStartWeapon != null)
        {
            Physics.IgnoreCollision(GetComponent <CapsuleCollider>(), sensor.leftStartWeapon.GetComponent <Collider>());
            actions.PickupObject(sensor.leftStartWeapon, sensor.leftHand, sensor.leftWeaponPos);
        }
    }
コード例 #30
0
 public void CallAction_Defend()
 {
     if (HeldObject != null)
     {
         print("Object not null");
         if (HeldObject.GetComponent <UnitActions>() == true)
         {
             print("Script not null");
             UnitActions actions = HeldObject.GetComponent <UnitActions>();
             if (actions.ActionAvailable)
             {
                 Debug.Log("DEFEND!!!");
                 actions.Action_Defend();
                 Cancel();
             }
         }
     }
     else
     {
         print("Object is null");
     }
 }
コード例 #31
0
ファイル: Brain.cs プロジェクト: AndreyMartunyk/TestGame
        private UnitActions BlindBeagle(GameRoom level, GameObject beagle)
        {
            UnitActions beagleAction = UnitActions.None;

            if (beagle.IsActive)
            {
                int        playerIndex  = level.FindPlayerIndex();
                Coordinate playerCenter = level.gameObj[playerIndex].ObjArea.GetCenter();
                Coordinate beagleCenter = beagle.ObjArea.GetCenter();

                int absX = Math.Abs(playerCenter.x - beagleCenter.x);
                int absY = Math.Abs(playerCenter.y - beagleCenter.y);

                if (absX > absY)
                {
                    if (playerCenter.x >= beagleCenter.x)
                    {
                        beagleAction = UnitActions.MoveRight;
                    }
                    else
                    {
                        beagleAction = UnitActions.MoveLeft;
                    }
                }
                else
                {
                    if (playerCenter.y >= beagleCenter.y)
                    {
                        beagleAction = UnitActions.MoveDown;
                    }
                    else
                    {
                        beagleAction = UnitActions.MoveTop;
                    }
                }
            }
            return(beagleAction);
        }
コード例 #32
0
    public static Unit[] GetTargetPool(this UnitActions action)
    {
        Unit[] targetPool;
        switch (action)
        {
        case UnitActions.Heal:
            targetPool = UnitManager.Instance.allies.Concat(UnitManager.Instance.currentEnemies).ToArray();
            break;

        case UnitActions.Attack:
            targetPool = UnitManager.Instance.currentEnemies.Concat(UnitManager.Instance.allies).ToArray();
            break;

        case UnitActions.StrongAttack:
            targetPool = UnitManager.Instance.currentEnemies.Concat(UnitManager.Instance.allies).ToArray();
            break;

        default:
            targetPool = null;
            break;
        }
        return(targetPool.Where(unit => unit.state != UnitStates.KnockedOut).ToArray());
    }
コード例 #33
0
ファイル: Movement.cs プロジェクト: point01/Square-Wars
    // CALL THIS EVERY TIME A UNIT GETS A NEW TURN
    public static void GenerateMovementTree(UnitActions mover)
    {
        System.Collections.Generic.List<Tile> all = new System.Collections.Generic.List<Tile>();
        //optimization
        int mx = (int)mover.gridPosition.x;
        int my = (int)mover.gridPosition.y;
        int mxmin = mx - mover.MovementTiles;
        int mxmax = mx + mover.MovementTiles;
        int mymin = my - mover.MovementTiles;
        int mymax = my + mover.MovementTiles;
        if (mxmin < 0)
            mxmin = 0;
        if (mxmax >= GameManager.MapWidth)
            mxmax = GameManager.MapWidth - 1;
        if (mymin < 0)
            mymin = 0;
        if (mymax >= GameManager.MapHeight)
            mymax = GameManager.MapHeight - 1;
        Tile temp = GetTileFromPlayer(mover);
        for (int i = mxmin; i <= mxmax; ++i)
        {
            for (int j = mymin; j <= mymax; ++j)
            {
                if (GetDistance(temp, GameManager.map[i][j]) < mover.MovementTiles + 1)
                    if (true) //TODO replace this with a check to see if the mover can walk on map[i][j]
                        all.Add(GameManager.map[i][j]);
            }
        }
        //TODO This will need to be tweaked if we allow movement through allied units
        //if allied movement is desired, this foreach can be removed to allow it, but you'll need to manually remove player location tiles
        // from the output of getmovement or they'll be able to walk into each other
        //uncomment this to make it so that allied units block player movement
        /*foreach (Player p in GameManager.currentTeam.myRoster)
        {
            temp = GetTileFromPlayer(p);
            if (all.Contains(temp))
                all.Remove(temp);
        }*/
        foreach (UnitActions p in GameManager.enemyTeam.myRoster)
        {
            temp = GetTileFromPlayer(p);
            if (all.Contains(temp))
                all.Remove(temp);
        }

        //Dijkstra's Algorithm
        Dictionary<Tile, int> weights = new Dictionary<Tile, int>();
        List<Tile> unvisited = new List<Tile>();
        Dictionary<Tile, Tile> nextParent = new Dictionary<Tile, Tile>();
        foreach (Tile t in all)
        {
            weights.Add(t, Infinity);
            unvisited.Add(t);
        }
        temp = GetTileFromPlayer(mover);
        weights[temp] = 0;
        unvisited.Remove(temp);
        CurrentMovementTree.Clear();
        CurrentMovementTree.Value = temp;
        while (unvisited.Count > 0)
        {
            List<Tile> uvn = GetUnvisitedNeighbors(unvisited, temp);
            int dist;
            foreach (Tile t in uvn)
            {
                float jdist = t.elevation - temp.elevation;
                if (jdist < 0)
                    jdist *= -1;
                if (t.isAccessible && jdist <= mover.MovementJump)
                    dist = t.MoveCost + weights[temp];
                else
                    dist = Infinity;
                if (dist < weights[t])
                {
                    weights[t] = dist;
                    if (nextParent.ContainsKey(t))
                        nextParent[t] = temp;
                    else
                        nextParent.Add(t, temp);
                }
            }
            if (unvisited.Count > 0)
            {
                temp = unvisited[0];
                foreach (Tile t in weights.Keys)
                {
                    if (unvisited.Contains(t) && weights[t] < weights[temp])
                        temp = t;
                }
            }
            unvisited.Remove(temp);
        }
        Queue<Tile> distancecheck = new Queue<Tile>();
        foreach (Tile t in nextParent.Keys)
        {
            distancecheck.Enqueue(t);
        }
        Queue<Tile> Remove = new Queue<Tile>();
        while (distancecheck.Count > 0)
        {
            if (weights[distancecheck.Peek()] > mover.MovementTiles)
                Remove.Enqueue(distancecheck.Dequeue());
            else
                distancecheck.Dequeue();
        }
        while (Remove.Count > 0)
            nextParent.Remove(Remove.Dequeue());
        RecursiveBuildTileTree(nextParent, CurrentMovementTree);
    }
コード例 #34
0
ファイル: Movement.cs プロジェクト: point01/Square-Wars
 public static Tile GetTileFromPlayer(UnitActions p)
 {
     return GameManager.map[(int)p.gridPosition.x][(int)p.gridPosition.y];
 }
コード例 #35
0
ファイル: Movement.cs プロジェクト: point01/Square-Wars
 public static System.Collections.Generic.List<Tile> GetMovement(UnitActions mover)
 {
     List<Tile> retval;
     retval = CurrentMovementTree.ToList();
     //retval.Remove(GetTileFromPlayer(mover));
     //stops the player from moving where units already exist
     Tile temp;
     foreach (UnitActions p in GameManager.currentTeam.myRoster)
     {
         temp = GetTileFromPlayer(p);
         if (retval.Contains(temp))
             retval.Remove(temp);
     }
     foreach (UnitActions p in GameManager.enemyTeam.myRoster)
     {
         temp = GetTileFromPlayer(p);
         if (retval.Contains(temp))
             retval.Remove(temp);
     }
     for(int i = retval.Count - 1; i > -1; --i)
     {
         if (retval[i] == null)
             retval.Remove(retval[i]);
     }
     return retval;
 }
コード例 #36
0
ファイル: Movement.cs プロジェクト: point01/Square-Wars
 public static System.Collections.Generic.Queue<Tile> GetMovementPath(UnitActions mover, Tile destination)
 {
     return CurrentMovementTree.GetMoveQueue(destination);
 }
コード例 #37
0
ファイル: Movement.cs プロジェクト: point01/Square-Wars
 public static System.Collections.Generic.List<Tile> GetAttack(UnitActions mover)
 {
     System.Collections.Generic.List<Tile> retval = new System.Collections.Generic.List<Tile>();
     for (int i = 0; i < GameManager.MapWidth; ++i)
     {
         for (int j = 0; j < GameManager.MapHeight; ++j)
         {
             if (GetDistance(GetTileFromPlayer(mover), GameManager.map[i][j]) < mover.AttackRange + 1)
                 retval.Add(GameManager.map[i][j]);
         }
     }
     return retval;
 }
コード例 #38
0
ファイル: GameManager.cs プロジェクト: point01/Square-Wars
    public void nextTurn()
    {
        //Check if game going
        if (!gameOver || !freezeGame)
        {
            //UserPlayerPrefab.GetComponent<UnitActionsPlayer>().StopEverything();
            Movement.UnPaintTiles();

            //Are all the players done with their turn
            bool turndone = true;
            int i;
            for (i = 0; turndone && i < currentTeam.myRoster.Count; ++i)
            {
                if ((currentTeam.myRoster[i].CanMove || currentTeam.myRoster[i].CanAttack) && currentTeam.myRoster[i].isAlive)
                {
                    turndone = false;
                    checkStatus(currentTeam.myRoster[currentPlayerIndex]);
                }
            }
            --i;
            currentPlayerIndex = i;
            /*            if (currentPlayerIndex + 1 < currentTeam.myRoster.Count)
                        {
                            checkStatus(currentTeam.myRoster[currentPlayerIndex]);
                            currentPlayerIndex++;
                            //Change teams and put counter at start of team
                        }
                        else*/
            if (turndone)
            {
                switch (currentTeam.teamName)
                {
                    case "Team1":
                        currentTeam = team2;
                        enemyTeam = team1;
                        team2TurnNum++;
                        break;
                    case "Team2":
                        currentTeam = team1;
                        enemyTeam = team2;
                        team1TurnNum++;
                        break;
                    default:
                        break;
                }
                currentPlayerIndex = 0;
                foreach (UnitActions a in currentTeam.myRoster)
                {
                    if (a.isAlive)
                    {
                        a.CanMove = true;
                        a.CanAttack = true;
                    }
                    if(a.unitClass.Equals("King") && !a.isAlive)
                    {
                        endGame();
                    }
                }
            }
            UnitActionsPlayer.MoveList = null;
            UnitActionsPlayer.AttackList = null;
            CurrentTurnPlayer = currentTeam.myRoster[currentPlayerIndex];

            //S_AI: Example of making a unit move with a script
            // move some of this code into unitactionsai or something
            if (CurrentTurnPlayer.unitType == "AI")
            {
                //  AITurn = true;
                AIControl.controlAI();
                //  AITurn = false;
            }
        }
    }
コード例 #39
0
ファイル: UnitActions.cs プロジェクト: point01/Square-Wars
    public void setUnitStatus(UnitActions unit)
    {
        if (unit.unitStatus.Equals("Normal"))
        {

        }

        if (unit.unitStatus.Equals("Poison"))
        {
            unit.isPoisoned = true;
        }
    }
コード例 #40
0
ファイル: UnitActions.cs プロジェクト: point01/Square-Wars
    /**************************************************************************************************************************
     * This method currently handles general unit combat. If the attacking unit has higher AGI, it'll attack first. Otherwise
     * the defending unit will attack first.
     *
     * @attacker The attacking unit. Can be either the User's unit or the Enemy (other user or AI).
     * @defender The unit that didn't start the attack. Can be either the User's unit or the Enemy (other user or AI).
     *
     *************************************************************************************************************************/
    public void unitCombat(UnitActions attacker, UnitActions defender)
    {
        //The damage the attacking unit will give
        int attackerDamage = attackDamage(attacker, defender);
        //The damage the defending unit will give
        int defenderDamage = attackDamage(defender, attacker);

        //If attacking unit has more AGI, it'll attack first
        if (attacker.unitAGI >= defender.unitAGI)
        {
            defender.unitHP = defender.unitHP - attackerDamage;
            if (defender.unitHP > 0)
            {
                attacker.unitHP = attacker.unitHP - defenderDamage;
            }
        }
        //If defending unit (non-attacking unit) has higher AGI, it will attack first
        else
        {
            attacker.unitHP = attacker.unitHP - defenderDamage;
            if (attacker.unitHP > 0)
            {
                defender.unitHP = defender.unitHP - attackerDamage;
            }
        }
    }
コード例 #41
0
ファイル: GameManager.cs プロジェクト: point01/Square-Wars
 public void checkStatus(UnitActions Unit)
 {
     if (Unit.isPoisoned == true)
     {
         Unit.unitHP -= 1;
         Unit.unitPoisonCounter -= 1;
         if (Unit.unitPoisonCounter == 0)
         {
             Unit.isPoisoned = false;
             Unit.unitPoisonCounter = 3;
             Unit.unitStatus = "Normal";
         }
     }
 }