static Hero PlayerSetup() { Console.WriteLine("What is your name?"); string name = Console.ReadLine(); string choice = "0"; while (choice != "1" && choice != "2" && choice != "3") { Console.WriteLine("Please type the number of the hero you would ike to be?\n1. Cowboy\n2. Gunslinger\n3. Sheriff"); choice = Console.ReadLine(); } switch (choice) { case ("1"): Cowboy cowboy = new Cowboy(name); return(cowboy); case ("2"): // Change Ninja to another class of hero. Gunslinger gunslinger = new Gunslinger(name); return(gunslinger); case ("3"): // Change Ninja to another class of hero. Sheriff sheriff = new Sheriff(name); return(sheriff); } return(null); }
private void StartNetworkPlayer() { GameObject cowboy = GameObject.Instantiate(Resources.Load <GameObject>("Cowboy")); //Create representation of the player connected m_Cowboy = cowboy.GetComponent <Cowboy>(); m_Cowboy.transform.SetParent(transform); m_Cowboy.transform.localPosition = Vector3.zero; m_Cowboy.transform.localRotation = Quaternion.identity; }
private void Start() { var clone = Instantiate(m_CowboyPrefab, transform); clone.transform.localRotation = Quaternion.identity; clone.transform.localPosition = Vector3.zero; clone.transform.localScale = Vector3.one; m_Cowboy = clone.GetComponent <Cowboy>(); m_Cowboy.InitialiseAsVr(GetComponent <Player>()); }
private void StartLocalPlayer() { VrPlayer vrplayer = FindObjectOfType <VrPlayer>(); m_Cowboy = vrplayer.GetCowBoy; CmdUpdateSeed(m_Cowboy.GetSeed); m_Cowboy.OnGunStateChange += OnPlayerGrabGun; m_Cowboy.OnGunFired += OnPlayerFiredGun; }
public void Start() { string sceneName = SceneManager.GetActiveScene().name; if(sceneName == "MenuScene") { SoundManager.GetInstance().PlaySoundBackground(SoundManager.SoundBackground.MenuBackgroundMusic); } else if(sceneName == "GameScene") { SoundManager.GetInstance().PlaySoundBackground(SoundManager.SoundBackground.BackgroundMusic); Cowboy.GetInstance().OnEnd += OnEnd; Cowboy.GetInstance().OnStart += OnStart; } }
public void Refresh(bool NextLvl) { Next.SetActive(false); Again.SetActive(true); countPlayerDelay = 0.0f; Cowboy.GetComponent <Animator>().SetBool("Stand", false); infoPanel.SetActive(false); if (NextLvl) { LoadLevel(MainMenu.s_LvlToLoad += 1); } else { LoadLevel(MainMenu.s_LvlToLoad); } }
public override PeopleINPC GetPeople(PeopleNPCType peopleType) { switch (peopleType) { case PeopleNPCType.Cityboy: PeopleINPC cityboy = new Cityboy(); return(cityboy); case PeopleNPCType.Cowboy: PeopleINPC cowboy = new Cowboy(); return(cowboy); case PeopleNPCType.Weenie: PeopleINPC weenie = new Weenie(); return(weenie); } return(null); }
private void Start() { spawnTime = initialSpawnTime; GameManager.GetInstance().ySpeed = GameManager.GetInstance().initialYSpeed; state = State.Waiting; assets = GameAssets.GetInstance(); pfFence = assets.pfFence; pfCoin = assets.pfCoin; Cowboy.GetInstance().OnStart += OnStart; Cowboy.GetInstance().OnEnd += OnEnd; possibleHoles = new List <int>(); allowedHoles = new List <int>(); for (int i = 0; i < spawnList.Count; i++) { possibleHoles.Add(i); } allowedHoles.AddRange(possibleHoles); }
private void Update() { delay -= Time.deltaTime; if (delay <= 0 && onceCalled) { text.text = "Shoot"; onceCalled = false; canClick = true; } if (delay <= 0) { Cowboy.GetComponent <Animator>().SetBool("Stand", true); countPlayerDelay += Time.deltaTime; reverseDelay -= Time.deltaTime; if (reverseDelay <= 0 && !win) { ShootBtn.GetComponent <BoxCollider2D>().enabled = false; infoPanel.SetActive(true); infoPanel.GetComponentInChildren <Text>().text = "You lost"; } } }
private void Awake() { instance = this; }
// Update is called once per frame void Update() { //arthurBody.transform.position = gameObject.transform.position; switch (_currentState) { case ArthurState.Wander: { Debug.Log("arthurPOS : " + transform.position); Debug.Log("A_Wander"); anim.Play("Arthur_walk"); if (aggroScript.NeedsDestination()) { Debug.Log("needsDestination"); aggroScript.GetDestination(); } Debug.Log("des:" + aggroScript._destination); transform.rotation = aggroScript._desiredRotation; transform.Translate(Vector3.forward * Time.deltaTime); gGlobal.fShoot = false; while (aggroScript.IsPathBlocked()) { Debug.Log("pathBlocked"); aggroScript.GetDestination(); } var targetToAggro = GetComponent <CheckAggroTest>().CheckForAggro(); if (targetToAggro != null) { _target = targetToAggro.GetComponent <Cowboy>(); _currentState = ArthurState.Chase; } break; } case ArthurState.Chase: { Debug.Log("A_Chase"); if (_target == null) { _currentState = ArthurState.Wander; return; } var targetToAggro = GetComponent <CheckAggroTest>().CheckForAggro(); if (targetToAggro != null) { Vector3 newArthurPos = new Vector3(_target.transform.position.x - 5f, _target.transform.position.y, _target.transform.position.z); agent.SetDestination(newArthurPos); //anim.Play("Arthur_takeGun"); _target = targetToAggro.GetComponent <Cowboy>(); _currentState = ArthurState.Attack; gGlobal.fShoot = false; Debug.Log("arthur : " + newArthurPos); Debug.Log("target : " + _target.transform.position); } break; } case ArthurState.Attack: { if (time >= 0) { time -= Time.deltaTime; //Debug.Log(time); return; } if (time <= 0 && _target != null) { anim.Play("Arthur_shoot"); Instantiate(bulletPrefab, bulletSpawn.position, Quaternion.identity); bulletPrefab.transform.LookAt(_target.transform.position); time = timeDuration; } if (gGlobal.fShoot == true) { _currentState = ArthurState.Wander; } break; } } }
private void Update() { switch (_currentState) { case NormalState.Wander: { Debug.Log("N_Wander"); if (aggroScript.NeedsDestination()) { aggroScript.GetDestination(); } transform.rotation = aggroScript._desiredRotation; transform.Translate(Vector3.forward * Time.deltaTime); anim.SetFloat("Forward", forwardAmount, 0.1f, Time.deltaTime); forwardAmount = Vector3.forward.z; while (aggroScript.IsPathBlocked()) { aggroScript.GetDestination(); } var targetToAggro = gameObject.GetComponent <CheckAggroTest>().CheckForAggro(); if (targetToAggro != null) { _target = targetToAggro.GetComponent <Cowboy>(); _currentState = NormalState.Escape; } break; } case NormalState.Escape: { Debug.Log("escaping"); if (_target == null) { _currentState = NormalState.Wander; return; } float distance = Vector3.Distance(transform.position, _target.transform.position); Debug.Log("N_distance"); Vector3 dirtoPlayer = transform.position - _target.transform.position; Vector3 newPos = (transform.position + dirtoPlayer); if (agent.SetDestination(newPos) == false) { Debug.Log("N_SetDest Error: " + dirtoPlayer.ToString() + ":" + newPos.ToString()); } if (distance >= _hideRange) { _currentState = NormalState.Hide; //agent.Stop(); } break; } case NormalState.Hide: { Debug.Log("Hiding"); _currentState = NormalState.Wander; break; } } }
//Actual program public static void Main(string[] args) { string inst; string[] commands; int[] matrix = new int[2]; int turn = 1; //Initialize player classes Cowboy p1 = new Cowboy(); p1.Life = 2; p1.Bullets = 0; p1.Cooldown = 0; Cowboy p2 = new Cowboy(); p2.Life = 2; p2.Bullets = 0; p2.Cooldown = 0; //Print Instructions Console.WriteLine("Two cowbows chose an action simultaneously."); Console.WriteLine("You can choose to Reload, Shoot, or Defend."); Console.WriteLine("It's Hiiiiiiigh Noooooooon!"); //Game loop while (true) { Console.WriteLine("----------[Turn " + turn + "]----------"); turn++; //Input (TBA: health memory for comparison when Shot with proxy var) matrix[0] = 3; matrix[1] = 3; inst = Console.ReadLine(); commands = inst.Split(','); Console.WriteLine("Draw!"); //Console.WriteLine("Player 1: " + commands[0] +" "+ "Player 2:" + commands[1]); //Input conversion p1 (Major issue: what if it contains multiple inputs?) if (commands[0].Contains("attack")) { matrix[0] = 0; } else if (commands[0].Contains("reload")) { matrix[0] = 1; } else if (commands[0].Contains("defend")) { matrix[0] = 2; } else { Console.WriteLine("Input 1 is invalid"); } //Input conversion p2 if (commands[1].Contains("attack")) { matrix[1] = 0; } else if (commands[1].Contains("reload")) { matrix[1] = 1; } else if (commands[1].Contains("defend")) { matrix[1] = 2; } else { Console.WriteLine("Input 2 is invalid"); } //Console.WriteLine("Matrix 1: " + matrix[0] +" "+ "Matrix 2: " + matrix[1]); //Catch Invalid moves (attackWithoutBullet, defendOnCooldown, restore enemy health damaged) if (p1.Bullets == 0 && matrix[0] == 0) { p1.Life--; p2.Bullets++; if (matrix[1] == 0) { p2.Life++; } if (matrix[1] == 1) { p2.Life++; p2.Bullets++; } } if (p1.Cooldown > 0 && matrix[0] == 2) { p1.Cooldown -= 3; if (matrix[1] != 0) { p1.Life--; } } if (p2.Bullets == 0 && matrix[1] == 0) { p2.Life--; p2.Bullets++; if (matrix[0] == 0) { p1.Life++; } if (matrix[0] == 1) { p1.Life++; p1.Bullets++; } } if (p2.Cooldown > 0 && matrix[1] == 2) { p2.Cooldown -= 3; if (matrix[0] != 0) { p2.Life--; } } //Results if (matrix[0] == 0 && matrix[1] == 0) { p1.Life--; p1.Bullets--; p2.Life--; p2.Bullets--; } else if (matrix[0] == 1 && matrix[1] == 0) { p1.Life--; p2.Bullets--; } else if (matrix[0] == 2 && matrix[1] == 0) { p1.Cooldown += 3; p2.Bullets--; } else if (matrix[0] == 0 && matrix[1] == 1) { p1.Bullets--; p2.Life--; } else if (matrix[0] == 1 && matrix[1] == 1) { p1.Bullets++; p2.Bullets++; } else if (matrix[0] == 2 && matrix[1] == 1) { p1.Cooldown += 3; p2.Bullets--; } else if (matrix[0] == 0 && matrix[1] == 2) { p1.Bullets--; p2.Cooldown += 3; } else if (matrix[0] == 1 && matrix[1] == 2) { p1.Bullets++; p2.Cooldown += 3; } else if (matrix[0] == 2 && matrix[1] == 2) { p1.Cooldown += 3; p2.Cooldown += 3; } //Reduce cooldowns by 1 if (p1.Cooldown > 0) { p1.Cooldown--; } if (p2.Cooldown > 0) { p2.Cooldown--; } //Maximum bullets? if (p1.Bullets > 1) { p1.Bullets = 1; } if (p2.Bullets > 1) { p2.Bullets = 1; } //Debug info Console.WriteLine("Player 1 Life: " + p1.Life + " " + "Player 2 Life: " + p2.Life); Console.WriteLine("Player 1 Bullets: " + p1.Bullets + " " + "Player 2 Bullets: " + p2.Bullets); Console.WriteLine("Player 1 Cooldown: " + p1.Cooldown + " " + "Player 2 Cooldown: " + p2.Cooldown); if (p1.Life == 0) { Console.WriteLine("Game Over! Player 2 Wins!"); break; } if (p2.Life == 0) { Console.WriteLine("Game Over! Player 1 Wins!"); break; } } }
// new players for every new test .. public Part4() { _marshall = new Marshall("Wyatt Earp"); _cowboy = new Cowboy("Curly Bill Brocius"); _gambler = new Gambler("Doc Holliday"); }
static void Main(string[] args) { var player = new Cowboy(); double aiTiming; //Menu Console.WriteLine("What is your name son?"); player.Name = Console.ReadLine(); Console.Clear(); Console.WriteLine("Which state you from son?"); player.State = Console.ReadLine(); Console.Clear(); Console.WriteLine($"==================== The Bar ====================\nListen up {player.Name} from {player.State}, these are the rules:\nTo become the fastest in the west, you press == W == to pull out your gun and == Enter == to shoot \n\nWhen you are ready select your difficulty\n1. Easy\n2. Normal\n3. Hard\n4. Impossible"); int difficulty = Convert.ToInt32(Console.ReadLine()); //Don't have to retype name and difficulty while (true) { //Round increment for (int i = 1; i < 99; i++) { //Difficulty settings if (difficulty == 1) { aiTiming = player.Easy(); } else if (difficulty == 2) { aiTiming = player.Normal(); } else if (difficulty == 3) { aiTiming = player.Hard(); } else if (difficulty == 4) { aiTiming = player.Impossible(); } else { Console.WriteLine("What an outlaw... Let's try again"); return; } Console.Clear(); Countdown(); Stopwatch sw = Stopwatch.StartNew(); var input = Console.ReadLine(); if (input == "w") { sw.Stop(); var timing = new Cowboy(); double speed = sw.Elapsed.TotalMilliseconds; Console.WriteLine("Damn cowboy, you pulled the trigger in: {0}ms", sw.Elapsed.TotalMilliseconds); Console.WriteLine($"While your oponent did it in: {aiTiming}ms"); if (speed < aiTiming) { Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine($"You won round {i}"); Console.ForegroundColor = ConsoleColor.Gray; Console.ReadKey(); } else { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine($"You died in round {i}"); Console.ForegroundColor = ConsoleColor.Gray; Console.ReadKey(); } } else { Console.WriteLine("You hit the wrong trigger cowboy"); Console.ReadKey(); } } } }
private void Update() { scoreText.text = Cowboy.GetInstance().GetScore().ToString(); }