Inheritance: MonoBehaviour
Beispiel #1
0
    public static IEnumerator Move()
    {
        GameBrain.ChangeAcceptInput(false);
        yield return(new WaitForSeconds(1.0f));

        HexCell moveTo;

        for (int i = 0; i < ai_units.Count; ++i)
        {
            if (ai_units[i] != null)
            {
                HexCell unit_cell = ai_units[i].CurrentHex;
                MoveMaster.SetTarget(ai_units[i]);
                moveTo = MapMaster.Map[ai_units[i].CurrentHex.R - 2, ai_units[i].CurrentHex.Q];
                MoveMaster.EvaluateTile(moveTo); //Actually moves unit
            }
        }
        yield return(new WaitForSeconds(.75f));

        while (MoveMaster.movingUnits != 0)
        {
            yield return(null);
        }

        yield return(GameBrain.ChangeTurn());
        //GameBrain.ChangeAcceptInput(true);
    }
Beispiel #2
0
 public static void LerpToView(RaycastHit hit) //Called by CheckClick below. Changes UI pannels and lerps to the position of the clicked cube
 {
     GameBrain.ChangeAcceptInput(false);
     UIMaster.FadePhanel((int)UIPannels.Action);
     UIMaster.FadePhanel((int)UIPannels.View);
     TopDownCamera.Instance.StartCoroutine(TopDownCamera.LerpToPosition(hit.transform.position, hit.transform.rotation));
 }
    void Start()
    {
        GameBrain.ChangeAcceptInput(false);
        TopDownCamera.AllowMovement(false);
        instance    = this;
        tm          = new TutorialUIMaster();
        t_ai        = new TutorialAI();
        acceptInput = false;
        ai_turn     = false;
        image_on    = false;
        turn_button = GameObject.Find("PlayerPanel").GetComponent <Button>();
        d_markers   = GameObject.Find("DeployMarkers");
        d_markers.SetActive(false);

        UIMaster.SetActionPanel(false);

        phase       = T_Phases.Introduction;
        whichText   = 0;
        phaselength = TutorialUIMaster.TutorialText[(int)phase].Length;
        TutorialUIMaster.ChangeText((int)phase, whichText);

        GameObject.Find("Back Button").GetComponent <Button>().onClick.AddListener(BackText);
        GameObject.Find("Forward Button").GetComponent <Button>().onClick.AddListener(ForwardText);
        GameObject.Find("Continue Button").GetComponent <Button>().onClick.AddListener(PlayersTurn);
        GameObject.Find("Raise Button").GetComponent <Button>().onClick.AddListener(RaiseBox);
    }
    void Start()
    {
        time = 0f;

        pacMan = GameObject.Find ("PacMan");
        gb = GameObject.Find ("GameBrain").GetComponent<GameBrain>();
    }
Beispiel #5
0
        // Update is called once per frame
        private void Update()
        {
            RotateView();
            // the jump state needs to read here to make sure it is not missed
            if (!m_Jump)
            {
                m_Jump = CrossPlatformInputManager.GetButtonDown("Jump");
            }

            if (this.gameObject.transform.position.y < -1)
            {
                this.gameObject.transform.position = new Vector3(0.0f, 3.5f, 0.0f);
                HeartsScript.heartsValue          -= 1;
            }

            if (!m_PreviouslyGrounded && m_CharacterController.isGrounded)
            {
                StartCoroutine(m_JumpBob.DoBobCycle());
                PlayLandingSound();
                m_MoveDir.y = 0f;

                newY = m_Camera.transform.position.y;
                Debug.Log("New.Y : " + newY);
                GameBrain.findTheHeighOfTheJump(oldY, newY);

                m_Jumping = false;
            }
            if (!m_CharacterController.isGrounded && !m_Jumping && m_PreviouslyGrounded)
            {
                m_MoveDir.y = 0f;
            }

            m_PreviouslyGrounded = m_CharacterController.isGrounded;
        }
Beispiel #6
0
 public static void ExitView() //Returns to the camera to the position is=t was at before clicking on the cube and switches the UI back
 {
     TopDownCamera.Instance.StartCoroutine(TopDownCamera.LerpToPosition(PlayerMaster.CurrentPlayer.CameraPosistion, PlayerMaster.CurrentPlayer.CameraRotation));
     TopDownCamera.AllowMovement(true);
     UIMaster.FadePhanel((int)UIPannels.Action);
     UIMaster.FadePhanel((int)UIPannels.View);
     GameBrain.ChangeAcceptInput(true);
 }
Beispiel #7
0
    public static IEnumerator IDontHaveCannons()
    {
        GameBrain.ChangeAcceptInput(false);
        yield return(new WaitForSeconds(2.0f));

        yield return(GameBrain.ChangeTurn());
        //GameBrain.ChangeAcceptInput(true);
    }
    void Start()
    {
        min = 15;
        max = 25;
        d = GameObject.FindGameObjectsWithTag("Dot").Length;

        gb = GameObject.Find ("GameBrain").GetComponent<GameBrain>();
    }
Beispiel #9
0
    void Start()
    {
        min = 25;
        max = 35;
        d = 220;

        isBonus = false;

        gb = GameObject.Find ("GameBrain").GetComponent<GameBrain>();
    }
Beispiel #10
0
    void Start()
    {
        time = 0f;

        pacMan = GameObject.Find ("PacMan");
        gb = GameObject.Find ("GameBrain").GetComponent<GameBrain>();
        bP = GameObject.Find ("FruitPlaces").GetComponent<BonusPoints>();

        bP.IsBonusItem();
    }
Beispiel #11
0
    //AI's current goal is destroying all enemies

    public static IEnumerator Deploy()
    {
        FillDeployment();

        //For the purposes of the alpha the AI only needs a single, reasonable deployment phase that it will use on each instance of the game.
        //Units should be reasonably spaced out. Cannons should spawn with enough units to carry them.
        //Some cannons will spawn with infantry. A small few will spawn with Cavalry.
        //In the future, deployment may be based on how the opponent has set up their deployment
        //Question: Are we going to use a point based system of deployment in the future, replacing the current X-amount-of-each-unit implementation

        for (int i = 0; i < 30; ++i)
        {
            GameObject g = (GameObject)GameObject.Instantiate(Resources.Load("prefabs/" + deployment[i] + (deployment[i] == "Cannon" ? "" : playernum.ToString())), PlayerMaster.CurrentPlayer.backLine[i].SpawnVector, Quaternion.identity);
            MapMaster.Map[PlayerMaster.CurrentPlayer.backLine[i].R, PlayerMaster.CurrentPlayer.backLine[i].Q].Unit            = g.GetComponent <Unit>();
            MapMaster.Map[PlayerMaster.CurrentPlayer.backLine[i].R, PlayerMaster.CurrentPlayer.backLine[i].Q].Unit.Player     = playernum;
            MapMaster.Map[PlayerMaster.CurrentPlayer.backLine[i].R, PlayerMaster.CurrentPlayer.backLine[i].Q].Unit.CurrentHex = PlayerMaster.CurrentPlayer.backLine[i];

            switch (deployment[i])
            {
            case ("Infantry"):
                Unit inf = g.GetComponent <Infantry>();
                PlayerMaster.CurrentPlayer.Inf.Add(inf);
                break;

            case ("Cavalry"):
                Unit cl = g.GetComponent <Cavalry>();
                PlayerMaster.CurrentPlayer.Cav.Add(cl);
                break;

            case ("Cannon"):
                Cannon c = g.GetComponent <Cannon>();
                c.Moved      = false;
                c.CurrentHex = PlayerMaster.CurrentPlayer.backLine[i];
                PlayerMaster.CurrentPlayer.Can.Add(c);
                break;
            }
            yield return(new WaitForSeconds(0.1f));
        }

        foreach (Cannon c in PlayerMaster.CurrentPlayer.Can)
        {
            Cluster(c);
        }
        foreach (Cavalry cv in PlayerMaster.CurrentPlayer.Cav)
        {
            Cluster(cv);
        }
        foreach (Infantry i in PlayerMaster.CurrentPlayer.Inf)
        {
            Cluster(i);
        }

        GameBrain.ChangeTurn();
    }
Beispiel #12
0
 void Awake()
 {
     //Debug.Log("Awake");
     if (!GameBrain.Instance) {
         Instance = this;
     } else {
         DestroyImmediate(gameObject);
         return;
     }
     DontDestroyOnLoad(gameObject);
 }
Beispiel #13
0
    public static IEnumerator DeployUnitsCoroutine()
    {
        GameBrain.ChangeAcceptInput(false);
        string  prefabpath = "Prefabs/";
        string  prefabName;
        HexCell h;

        foreach (UnitOrder uO in instance.uoList)
        {
            yield return(new WaitForSeconds(0.1f));

            h           = MapMaster.Map[uO.R, uO.Q];
            prefabName  = ((UnitTypes)uO.unitType).ToString();
            prefabName += prefabName == "Cannon" ? "" : PlayerMaster.CurrentTurn.ToString();

            Unit u = ((GameObject)GameObject.Instantiate(Resources.Load(prefabpath + prefabName), h.SpawnVector, Quaternion.identity)).GetComponent <Unit>();

            u.UDirection = (int)(PlayerMaster.CurrentTurn == 0 ? UnitRotations.half : UnitRotations.none);
            u.Player     = PlayerMaster.CurrentTurn;
            u.gameObject.transform.rotation = u.URotation();

            MapMaster.Map[uO.R, uO.Q].Unit            = u;
            MapMaster.Map[uO.R, uO.Q].Unit.CurrentHex = MapMaster.Map[uO.R, uO.Q];


            switch (uO.unitType)
            {
            case (0):
                PlayerMaster.CurrentPlayer.Inf.Add(u);
                break;

            case (1):
                PlayerMaster.CurrentPlayer.Cav.Add(u);
                break;

            case (2):
                Cannon c = (Cannon)u;
                c.shots = 0;
                PlayerMaster.CurrentPlayer.Can.Add(c);
                break;
            }

            GameObject.Destroy(uO.icon);

            ScoreMaster.GivePoints(ScoreMaster.PointValues[uO.unitType], u.Player);

            UIMaster.DisplayScore();
        }

        instance.uoList.Clear();
        RefreshUnitsUsed();
        GameBrain.ChangeAcceptInput(true);
    }
Beispiel #14
0
 void Awake()
 {
     //Debug.Log("Awake");
     if (!GameBrain.Instance)
     {
         Instance = this;
     }
     else
     {
         DestroyImmediate(gameObject);
         return;
     }
     DontDestroyOnLoad(gameObject);
 }
Beispiel #15
0
    public static IEnumerator Move() //WIP AI movement. Currently kept simple for the purpose of making it into the alpha. Made a coroutine so the player can see each step
    {
        //Cannons move first and prioritize getting in range of an enemy but do not move if already in range of an enemy

        //yield return new WaitForSeconds(2.0f);

        //Cavalry and Infantry will move after and prioritize geting in range of the closest enemy
        //Closest enemy is relative to each unit. Units will not move if already adjacent to an enemy

        for (int s = 0; s < SquadMaster.Count; ++s)
        {
            otherlist = SquadMaster[s];
            bool noCannons = true;

            for (int i = 0; i < otherlist.Count; ++i)
            {
                if (otherlist[i].gameObject.tag == "cannon" && otherlist[i] != null)
                {
                    noCannons = false;
                    //Debug.Log("Found cannon");
                }
            }

            if (noCannons)
            {
                FindClosestEnemy();
                yield return(new WaitForSeconds(.2f));

                MoveLeadSoldier();
                otherlist[0].StartCoroutine(MoveFollowers());
                while (moving) //boolean that is changed via MoveFollowers
                {
                    yield return(null);
                }
            }
            else //Move cannons forward about 2 spaces, then move the units nearby 2 spaces as well
            {
                MoveCannon();
                yield return(new WaitForSeconds(.2f));

                otherlist[0].StartCoroutine(MoveCannonFollowers());
                while (moving) //boolean that is changed via MoveCannonFollowers
                {
                    yield return(null);
                }
            }
        }
        GameBrain.ChangeTurn();
    }
Beispiel #16
0
        public MainWindow()
        {
            InitializeComponent();
            _log       = new SimpleLogger();
            _gameBrain = new GameBrain(_log);

            if (_gameBrain.GetGamesCount() == 0)
            {
                MessageBox.Show("No games found! Please check the settings JSON", "Fatal Error", MessageBoxButton.OK, MessageBoxImage.Error);
                Application.Current.Shutdown();
            }
            InitializeScoreBlocks(DefaultValues.TEAMNAMES);
            _scoreBoard = new ScoreBoard(_log);
            _random     = new Random();
            UpdateMainWindow();
        }
Beispiel #17
0
 public static IEnumerator Deploy()
 {
     GameBrain.ChangeAcceptInput(false);
     for (int i = 19; i < 29; ++i)
     {
         GameObject g = (GameObject)GameObject.Instantiate(Resources.Load("prefabs/Infantry1"), PlayerMaster.CurrentPlayer.backLine[i].SpawnVector, Quaternion.identity);
         ai_units.Add(g.GetComponent <Unit>());
         MapMaster.Map[PlayerMaster.CurrentPlayer.backLine[i].R, PlayerMaster.CurrentPlayer.backLine[i].Q].Unit            = g.GetComponent <Unit>();
         MapMaster.Map[PlayerMaster.CurrentPlayer.backLine[i].R, PlayerMaster.CurrentPlayer.backLine[i].Q].Unit.Player     = 1;
         MapMaster.Map[PlayerMaster.CurrentPlayer.backLine[i].R, PlayerMaster.CurrentPlayer.backLine[i].Q].Unit.CurrentHex = PlayerMaster.CurrentPlayer.backLine[i];
         PlayerMaster.CurrentPlayer.Inf.Add(g.GetComponent <Unit>());
         yield return(new WaitForSeconds(0.2f));
     }
     //GameObject cannon = (GameObject)GameObject.Instantiate(Resources.Load("prefabs/Cannon"), PlayerMaster.CurrentPlayer.backLine[30].SpawnVector, Quaternion.identity);
     yield return(GameBrain.ChangeTurn());
     //GameBrain.ChangeAcceptInput(true);
 }
Beispiel #18
0
    //initialize
    void Start()
    {
        instance = this;
        // canSkip = false;
        uiM = new UIMaster();
        sM  = new ScoreMaster();
        mM  = new MapMaster();
        pM  = new PlayerMaster();
        dM  = new DeployMaster();
        mvM = new MoveMaster();
        aM  = new AttackMaster();

        acceptInput = true;
        turnNum     = 0;

        CannonMaster.ResetCurrent();

        gP = GamePhase.Deploy;
        ScoreMaster.ResetScore();

        mL = new MapLoader();
        mL.LoadMapFromTextAsset(((TextAsset)Resources.Load("Maps/" + mapName)));
        PlayerMaster.SetBackLines(MapMaster.Map);
        TopDownCamera.ActivateMainCamera(MapMaster.Height, MapMaster.Width, MapMaster.MapRadius);

        UIMaster.SetGeneralUI();
        UIMaster.SetDeployUI();
        UIMaster.SetCannonUI();
        UIMaster.DisplayScore();

        UIMaster.SetPanelAlpha(false, (int)UIPannels.Cannon);
        UIMaster.SetPanelAlpha(false, (int)UIPannels.Phase);
        UIMaster.SetPanelAlpha(false, (int)UIPannels.View);
        UIMaster.SetPanelAlpha(false, (int)UIPannels.Fight);

        UIMaster.SetActionPanel(true);

        if (!tutorial)
        {
            UIMaster.DisplayState(gP, PlayerMaster.CurrentTurn);
        }

        // norton = VS_AI ? new AIBrain() : null; // must be called after UIMaster.SetGeneralUI to percive turns properly
    }
Beispiel #19
0
    // Start is called before the first frame update
    void Awake()
    {
        //QualitySettings.vSyncCount = 1;
        //Application.targetFrameRate = 50;
        instance = this;
        CreatePatternData();

        /*WriteEffect1();
        *  WriteEffect2();*/
        WriteEffect3();
        //zMin = 10;
        //DrawCheckerboard();

        /*Effect0 = new PatternParent2D();
         * Effect0.Draw(10);*/

        //Greetings effect0 = new Greetings();

        /*Invaders effect0 = new Invaders();
         * Effect0 = effect0;
         * byte[][] pattern = new byte[4][];
         * for (int z = 0; z < 4; z++) {
         * pattern[z] = new byte[invadersbpl.Length];
         * invadersbpl.CopyTo(pattern[z], 0);
         * }*/

        /*effect0.colors = new Color[] { new Color(255, 255, 0), new Color(235, 0, 0)
         *         , new Color(225, 0, 0), new Color(215, 0, 0), new Color(205, 0, 0)
         *         , new Color(195, 0, 0), new Color(185, 0, 0)
         *         , new Color(175, 0, 0),
         *         new Color(165, 0, 0), new Color(155, 0, 0)
         *         , new Color(255, 0, 0), new Color(255, 0, 0), new Color(255, 0, 0)
         *         , new Color(255, 0, 255), new Color(255, 255, 255)
         *         , new Color(255, 0, 0) };*/

        //effect0.Draw(pattern, 8, 35, 64, 25, 22, 10, -0.0125f, 1.1f);
        //effect0.Draw(pattern, 2, 42, 49, -0.2f);
        //effect0.Draw(pattern, 2, 42, 49, -0.096f,81,15);
        //effect0.Draw(rawghostown, 4, 42, 49, -0.041f, 71, 7); //favorite
        //effect0.Draw(rawghostown, 4, 42, 49, -0.0125f, 71, 3);
        // Update is called once per frame
    }
Beispiel #20
0
 public void Start()
 {
     gb = gameObject.GetComponent <GameBrain> ();
     sm = gameObject.GetComponent <ManageScene> ();
 }
Beispiel #21
0
 void Start()
 {
     state = true;
     gameover = GameObject.Find("GameBrain").GetComponent<GameBrain>();
     ghosts = GameObject.FindGameObjectsWithTag("Enemy");
 }
Beispiel #22
0
    public static IEnumerator Fight()
    {
        yield return(new WaitForSeconds(2)); //Gives the player a chance to see which units are about to fight

        GameBrain.ChangeTurn();
    }
Beispiel #23
0
 void Start()
 {
     state = true;
     gameover = GameObject.Find("GameBrain").GetComponent<GameBrain>();
 }
Beispiel #24
0
 void Start()
 {
     winner = GameObject.Find ("GameBrain").GetComponent<GameBrain>();
     loser = GameObject.Find ("GameBrain").GetComponent<GameBrain>();
 }
 void Start()
 {
     c = GameObject.Find ("GameBrain").GetComponent<GameBrain>(); //pekar på Klassen GameBrain hos GameObjectet GameBrain
 }
Beispiel #26
0
 void Start()
 {
     t = GameObject.Find ("GameBrain").GetComponent<GameBrain>();
 }
Beispiel #27
0
 void Start()
 {
     gameBrain = GameBrain.Instance;
 }
Beispiel #28
0
    IEnumerator HandleCannons(Cannon can)
    {
        Debug.Log("handling " + can.gameObject.name);
        CannonMaster.SetAICannon(can);
        canc  = can.transform.GetChild(0).transform.GetChild(0).GetComponent <CannonControll>();
        aimAt = CenterOfCluster(); //asigns aimAt as the center of the cluster
        cube.transform.position = aimAt;
        Vector3 dir = aimAt - can.transform.position;

        angle = Vector3.SignedAngle(dir, can.transform.GetChild(0).transform.forward, Vector3.up); //math to figure out the difference between the target's position and where the cannon is currently looking

        if (angle > 0)
        {
            while (angle > 2.0f)
            {
                //moves cannon left until it is lined up with target
                canc.lefts();
                angle = Vector3.SignedAngle(dir, can.transform.GetChild(0).transform.forward, Vector3.up);
                yield return(null);
            }
        }
        else
        {
            while (angle < -2.0f)
            {
                //moves cannon right until it is lined up with target
                canc.rights();
                angle = Vector3.SignedAngle(dir, can.transform.GetChild(0).transform.forward, Vector3.up);
                yield return(null);
            }
        }
        for (int i = 17; i >= 0; --i)
        {
            //Moves cannon's aim downward so that later we only have to move it up to line up shots
            canc.downs();
            yield return(null);
        }
        for (int i = 30; i >= 0; --i)
        {
            //Sets cannon at max power to more easily line up shots. Will more than likely be changed later to make lob shots possible
            canc.Powerup();
            yield return(null);
        }
        RaycastHit ray;
        int        num = canc.RayCastEnemies(out ray); //function created in CannonControl. Checks if a unit is within the current cannon's path

        RaycastHit hit;

        Physics.Raycast(new Ray(cube.gameObject.transform.position + Vector3.up, Vector3.down), out hit, 2.0f, 1 << 8);

        if (hit.transform != null)
        {
            Debug.Log(hit.transform);
            if (hit.transform.gameObject.GetComponent <HexCell>() != null)
            {
                GeneticCannon.goal = hit.transform.gameObject.GetComponent <HexCell>();
                Debug.Log(GeneticCannon.goal.ToString());
                yield return(GeneticCannon.SolveCannon());
            }
            else
            {
                GeneticCannon.goal = currentCluster[0].CurrentHex;
            }
        }

        while (num != -1)
        {
            //Move aim up until a unit is found
            //Needs to be modified to confirm the current target and avoid allies
            canc.ups();
            num = canc.RayCastEnemies(out ray);
            yield return(null);
        }

        canc.firecannon();


        //StartCoroutine(AimAndShoot(can));

        while (!combat.checkUnits)
        {
            yield return(null);
        }
        //Check units becomes true when a unit has been touched by a cannonball and becomes false once all "dead" units are removed from play
        while (combat.checkUnits)
        {
            yield return(null);
        }

        //if (inRangeTargets[target] == null)
        // ++target; //If target is dead, move to the next one
        //need proper target reprioritizing

        if (can.shots != 0) //if there is ammo left in the cannon, shoot again with the same cannon
        {
            inRangeTargets.Clear();
            currentCluster.Clear();
            biggestCluster.Clear();
            //yield return new WaitForSeconds(10f);
            FindTargets(can);
        }
        else
        {
            while (currentCannon < PlayerMaster.CurrentPlayer.Can.Count && PlayerMaster.CurrentPlayer.Can[currentCannon].shots == 0) //Moves through cannons until we are out of available cannons or we find one with enough shots
            {
                ++currentCannon;
            }

            if (currentCannon < PlayerMaster.CurrentPlayer.Can.Count && PlayerMaster.OtherPlayer.Inf.Count > 0) //If we found a cannon that can be shot
            {
                //yield return new WaitForSeconds(10f);
                inRangeTargets.Clear();
                currentCluster.Clear();
                biggestCluster.Clear();
                FindTargets(PlayerMaster.CurrentPlayer.Can[currentCannon]); //Find the targets within it's range and continue from there
            }
            else
            {
                Debug.Log("Out of cannons");
                StartCoroutine(CannonMaster.LeaveCannon()); //If we are out of cannons then zoom back out
                GameBrain.ChangeTurn();
            }
        }
    }
Beispiel #29
0
 void Start()
 {
     gameBrain = GameBrain.Instance;
 }