void Start() { yourCards = new List <GameObject> (); opponentCards = new List <GameObject> (); ai = opponentDeck.GetComponent <AIScript> (); nextTurn.GetComponent <Button> ().onClick.AddListener(NextTurn); player1Cards = new List <CardData> (); player2Cards = new List <CardData> (); for (int i = 0; i < allcardsData.Count; i++) { var temp = allcardsData [i]; int rand = UnityEngine.Random.Range(i, allcardsData.Count); allcardsData [i] = allcardsData [rand]; allcardsData [rand] = temp; } for (int i = 0; i < (allcardsData.Count / 2); i++) { player1Cards.Add(allcardsData [i]); Debug.Log(player1Cards [i].value); } for (int i = (allcardsData.Count / 2); i < allcardsData.Count; i++) { player2Cards.Add(allcardsData [i]); Debug.Log(player2Cards [i - allcardsData.Count / 2].value); } }
//private float aiAvoidStart = 0; // The time at which an AI started to avoid an object in its way // Start is called before the first frame update private void Start() { rb = GetComponent <Rigidbody2D>(); gc = GameObject.FindGameObjectWithTag("GameController").GetComponent <GameController>(); myTransform = GetComponent <Transform>(); myCollider = GetComponent <CircleCollider2D>(); myMagnitude = myTransform.localScale.magnitude; colRadius = myCollider.radius; if (isPlayer) { myCamera = GameObject.FindGameObjectWithTag("MainCamera").GetComponent <Camera>(); cameraToCircleRatio = myTransform.localScale.magnitude / myCamera.orthographicSize; minZoom = gc.minZoom; maxZoom = gc.maxZoom; absoluteMaxZoom = gc.absoluteMaxZoom; zoomRatio = maxZoom / minZoom; deathCam = GameObject.FindGameObjectWithTag("DeathCamera").GetComponent <Camera>(); deathCam.gameObject.SetActive(false); //Debug.Log(cameraToCircleRatio); } if (!isPlayer) // Players are always green (maybe I'll make a colour picker at some point); { GetComponent <SpriteRenderer>().color = Random.ColorHSV(); myAI = GetComponent <AIScript>(); } }
void Start() { passEnum = GetComponent <AIScript>(); animator = GetComponent <Animator>(); lastWaypointIndex = waypoints.Count - 1; //minusing by 1 because waypoints system starts at 0 targetWaypoint = waypoints[targetWaypointIndex]; //matching the transform to the waypointsindex }
// Use this for initialization void Start() { aiScript = GetComponent <AIScript>(); body = GetComponent <Rigidbody2D>(); myCollider = GetComponent <BoxCollider2D>(); myAnimator = GetComponent <Animator>(); }
void StartCrime() { perpetrator = SelectPerpetrator(); perpScript = perpetrator.GetComponent <AIScript> (); perpScript.CommitCrime(gameObject.transform.position, gameObject.GetComponent <CrimeSceneScript>()); }
// Use this for initialization void Start() { aiScript = GetComponent <AIScript> (); aiTurretScript = GameObject.FindGameObjectWithTag("StaticAI1").GetComponent <AITurretScript> (); arrayList = new float[4]; }
/// <summary> /// Called when someone won the game on AI screen /// </summary> private static void GameWonAI(Cell.CellOcc type) { AIScript ai = GameObject.FindObjectOfType <AIScript>(); IncrementAchievement(achievementTenGamesAgainstAi); IncrementAchievement(achievementFiftyGamesAgainstAi); IncrementAchievement(achievement100GamesAgainstAi); IncrementAchievement(achievement1000GamesAgainstTheAi); // Player won if (type != AIScript.AIType) { IncrementAchievement(achievement10WinsAgainstTheAi); IncrementAchievement(achievement50WinsAgainstTheAi); IncrementAchievement(achievement100WinsAgainstTheAi); IncrementAchievement(achievement250WinsAgainstTheAi); IncrementAchievement(achievement1000WinsAgainstTheAi); // won against hard difficulty if (ai.Difficulty == 3) { IncrementAchievement(achievementWin50TimesAgainstHardAi); IncrementAchievement(achievementWin250TimesAgainstTheHardAi); IncrementAchievement(achievementWin1000TimesAgainstTheHardAi); } } GameWon(type); }
private Rectangle GetLinkBoxPosition(ScriptBoxTypes ScriptBoxType, AIScript ActiveScript, int Index) { int ScriptX = ActiveScript.ScriptSize.X; int ScriptY = ActiveScript.ScriptSize.Y; switch (ScriptBoxType) { case ScriptBoxTypes.FollowingScript: return(new Rectangle( ScriptX + ActiveScript.ScriptSize.Width + 4, ScriptY + ActiveScript.ScriptSize.Height - 11 - Index * 12, 6, 6)); case ScriptBoxTypes.Reference: int SpacesBetweenReferences = ActiveScript.ScriptSize.Width / (ActiveScript.ArrayReferences.Length + 1); int DistanceFromCenter = SpacesBetweenReferences * (Index + 1) - ActiveScript.ScriptSize.Width / 2; return(new Rectangle( ScriptX - 1 + SpacesBetweenReferences * (Index + 1) + DistanceFromCenter / 5, ScriptY - 11, 6, 6)); case ScriptBoxTypes.Evaluator: return(new Rectangle(ScriptX - 11, ScriptY + 14, 6, 6)); default: case ScriptBoxTypes.GetContent: return(new Rectangle(ScriptX - 1 + ActiveScript.ScriptSize.Width / 2, ScriptY + ActiveScript.ScriptSize.Height + 4, 6, 6)); } }
private void diasbleAllController() { AIScript ai = GetComponent <AIScript>(); PlayerController player = GetComponent <PlayerController>(); WheelController[] wheels = GetComponentsInChildren <WheelController>(); if (ai != null) { ai.PauseAI(); } if (player != null) { player.enabled = false; } foreach (WheelController wheel in wheels) { if (wheel != null) { //wheel.enabled = false; // fake freezing wheel.setMeshRotationFlag(false); } } }
void Start() { tm = GetComponentInChildren <TextMesh>(); gms = GameManagerScript.instance; pf = GetComponent <PathFollower>(); if (isPlayer) { isPlayer = true; GameObject.FindGameObjectWithTag("MainCamera").GetComponent <CameraFollowScript>().SetCamera(this.transform); UIManagerScript.instance.mainPlayerStats = this.GetComponent <Statistics>(); ps = GetComponent <PlayerScript>(); GetComponent <AIScript>().enabled = false; } else { isPlayer = false; ais = GetComponent <AIScript>(); GetComponent <PlayerScript>().enabled = false; } // gms.stats.Add(this.GetComponent<Statistics>()); gms.AddToStats(GetComponent <Statistics>()); tm.text = playerName; thisTransform = GetComponent <Transform>(); startZ = thisTransform.position.z; goalZ = GameObject.FindGameObjectWithTag("Goal").GetComponent <Transform>().position.z; divZ = goalZ - startZ; }
void Start() { rgd = GetComponent <Rigidbody2D>(); ip = new InputPacket(); input = GetComponent <AIScript>(); Debug.Log(input); }
void Start() { grid = GetComponent <Grid>(); gameLogic = GetComponent <AITTTGameLogic>(); aiScript = GetComponent <AIScript>(); canvasScaler = GameObject.Find("Canvas").GetComponent <CanvasScaler>(); Color htc = helpText.color; htc.a = 0; helpText.color = htc; // change think time of ai to a bit more gameLogic.aiMinThinkTime = 1.3f; // change ai difficulty to really ahrd first so the player doesnt get throught the first like 20 signs for sure aiScript.SetDifficulty(4); // subscribe to placed sign event grid.SignWasPlacedEvent += SignWasPlayed; gameLogic.SomeoneWonGameEvent += SomeoneWonGame; clickImge.DOFade(1f, 0.2f); clickImge.rectTransform.DOScale(1.1f, 0.6f).SetLoops(-1, LoopType.Yoyo); ScaneManager.Instance.backButtonEnabled = false; }
public static TraitDataClass PickRandomTrait(AIScript perpScript) { int traitNumber = Random.Range (0, 4); TraitDataClass[] traits = { perpScript.coat, perpScript.glasses, perpScript.hat, perpScript.hair }; TraitDataClass traitChoice = traits [traitNumber]; return traitChoice; }
void BalanceCommunists() { //This method makes sure that the number of communists never exceeds the communist limit, and tries to add new communists when possible //the first if statement finds the current communist with the lowest communism characteristic, and removes it from the communist list //The second simply tries to add more communist to the list //This method activates every frame, so hopefully it won't affect the fps. If not we can optimise it later if (communists.Count > communistLimit) { int communismCheck = 100; GameObject deleteTarget = communists [0]; foreach (GameObject person in communists) { AIScript script = person.GetComponent <AIScript> (); if (script.GetCommunism() < communismCheck) { deleteTarget = person; communismCheck = script.GetCommunism(); } } communists.Remove(deleteTarget); } if (communists.Count < communistLimit) { FindCommunists(); } }
private void OnCollisionEnter(Collision collision) { AIScript enemy = collision.gameObject.GetComponent <AIScript>(); if ((collision.gameObject.tag == "Enemy" || collision.gameObject.tag == "Boss") && dangerous) { if (enemy.isBoss) { enemy.healthBar.fillAmount = enemy.hp / enemy.orighp; } enemy.hp -= damage; if (enemy.hp <= 0) { enemy.asource.enabled = true; enemy.asource.Play(); Destroy(collision.gameObject); float goldReward = enemy.getGoldReward(); GameObject.FindGameObjectWithTag("MainCamera").GetComponent <PlayerScript>().addToGold(goldReward); Instantiate(expl, collision.gameObject.transform.position, Quaternion.identity); } } if (collision.gameObject.tag == "Nodes") { dangerous = false; } }
public override void Start() { base.Start(); aiScript = GetComponent <AIScript>(); scoring = FindObjectOfType <ScoringScript>(); whoseTurn = AIScript.HumanType; }
//0 = small, 2 = med, 4 large private void OnTriggerEnter(Collider other) { AIScript Kart = other.GetComponent <AIScript>(); if (Kart != null) { Kart.EnterDriftZone(DriftSize); } }
private void OnTriggerExit(Collider other) { AIScript Kart = other.GetComponent <AIScript>(); if (Kart != null) { Kart.ExitDriftZone(); } }
public override void OnScriptLoad(AIScript NewScript) { DeathmatchScript NewDeathmatchScript = NewScript as DeathmatchScript; if (NewDeathmatchScript != null) { NewDeathmatchScript.Info = _Info; } }
public override void OnScriptLoad(AIScript NewScript) { TripleThunderScript NewTriplerThunderScript = NewScript as TripleThunderScript; if (NewTriplerThunderScript != null) { NewTriplerThunderScript.Info = _Info; } }
public static TraitDataClass PickRandomTrait(AIScript perpScript) { int traitNumber = Random.Range(0, 4); TraitDataClass[] traits = { perpScript.coat, perpScript.glasses, perpScript.hat, perpScript.hair }; TraitDataClass traitChoice = traits [traitNumber]; return(traitChoice); }
public void CommunicateShort(GameObject obj) { other = (AIScript)obj.GetComponent(typeof(AIScript)); AgentInfo info = new AgentInfo(this.influenceMap, this.lastPlayerPos, this.currentBehaviour); if (other != null) { ((AIScript)other).ReceiveInfo(info); } }
void Awake() { //determines which side is player /* * Set these next two booleans to control who is playing which side. All four combinations * are possible: Human-Human, Human-AI, AI-Human, AI-AI. In all cases, black plays first. * * IMPORTANT: even though both of these variables are "public" and are exposed in the * Inspector, changing them has no effect for some reason. This is a known issue. * * To get the paring you want, force those values here instead. * * If you are feeling ambitious, you could add a button to the UI that allows the player * to change who-plays-what and which AI to use to avoid having to change these manually. */ isPlayerOneAI = false; //aiToUseFor1 = 0; isPlayerTwoAI = true; //aiToUseFor2 = 1; Debug.Log("AI for one is: " + aiToUseFor1); Debug.Log("AI for two is: " + aiToUseFor2); /* For the calls to System.Reflection.Assembly.GetExecutingAssembly() below, enter the * string that names your .cs module that contains your AI code, such as is shown here * for RandomAI. Do this in two places if you want to let the AI play either as Black * or White. Or you could try dragging the module name into the "Player One Script Class" * or ""Player Two Script Class" in the Inspector for the Reversi game board. */ possibleMovesArray = new List <GameObject>(); if (isPlayerOneAI) { System.Type scriptType = System.Reflection.Assembly.GetExecutingAssembly().GetType("SmartBehavior"); //System.Type scriptType = System.Reflection.Assembly.GetExecutingAssembly().GetType(playerOneScriptClassName); System.Object o = Activator.CreateInstance(scriptType); playerOneScript = (AIScript)o; playerOneScript.setColor(BoardSpace.BLACK); playerOneScript.SetAI(aiToUseFor1); } if (isPlayerTwoAI) { //System.Type scriptType = System.Reflection.Assembly.GetExecutingAssembly().GetType(playerTwoScriptClassName); System.Type scriptType = System.Reflection.Assembly.GetExecutingAssembly().GetType("NaiveBehavior"); System.Object o = Activator.CreateInstance(scriptType); playerTwoScript = (AIScript)o; playerTwoScript.setColor(BoardSpace.WHITE); playerTwoScript.SetAI(aiToUseFor2); } InitBoard(); }
public void ComminicateLong() { communicating = true; AgentInfo info = new AgentInfo(this.influenceMap, this.lastPlayerPos, this.currentBehaviour); int childCnt = handler.transform.childCount; for (int i = 0; i < childCnt; i++) { AIScript other = (AIScript)handler.transform.GetChild(childCnt).GetComponent(typeof(AIScript)); other.ReceiveInfo(info); } //yield return new WaitForSeconds(2); }
void Start() { waypoints = GetComponent <WaypointsScript>(); aiScript = GetComponent <AIScript>(); textHandler = GameObject.FindGameObjectWithTag("Text").GetComponent <UIText>(); player.GetComponent <PlayerController>().enabled = false; currentAIStates = AIStates.Speaking; rigidBody = GetComponent <Rigidbody>(); controller = GetComponent <CharacterController>(); animator = GetComponent <Animator>(); controller.enabled = true; waypoints.enabled = false; }
void FindCommunists() { //Takes all the citizens, and finds the magnitude of their communist characteristic //If it is at or above five, it adds them to the communism group foreach (GameObject person in citizens) { AIScript script = person.GetComponent <AIScript> (); if (script.GetCommunism() >= 5) { communists.Add(person); } } }
protected override void Enable() { if (!AIScript.dashLayerEnabled) { return; } if (!CanPlay()) { return; } base.Enable(); if (Random.Range(0, 101) > hitChances[(int)AIScript.aiLevel]) { return; } if (AIScript.closerPlayers.Count == 0) { return; } if (AIScript.dashState != DashState.CanDash) { return; } int triesCount = 0; do { if (triesCount == 20) { return; } AIScript.dashMovement = (AIScript.closerPlayers[0].transform.position - transform.position).normalized; AIScript.dashMovement = Quaternion.AngleAxis(Mathf.Sign(Random.Range(-1f, -1f)) * Random.Range(randomAngles[(int)AIScript.aiLevel].randomAngleMin, randomAngles[(int)AIScript.aiLevel].randomAngleMax), Vector3.up) * AIScript.dashMovement; triesCount++; }while (DangerousCubes(AIScript.dashMovement)); AIScript.dashState = DashState.Dashing; AIScript.dashMovement.Normalize(); StartCoroutine(AIScript.Dash()); }
private void panDrawingSurface_MouseUp(object sender, MouseEventArgs e) { Rectangle MouseRec = new Rectangle(e.X + ScriptStartingPos.X, e.Y + ScriptStartingPos.Y, 1, 1); #region Action Scripts for (int S = AI.ListScript.Count - 1; S >= 0; --S) { if (ScriptLink == AI.ListScript[S]) { continue; } AIScript ActiveScript = AI.ListScript[S]; int X = ActiveScript.ScriptSize.X - ScriptStartingPos.X; int Y = ActiveScript.ScriptSize.Y - ScriptStartingPos.Y; if (MouseRec.IntersectsWith(AI.ListScript[S].ScriptSize)) { if ((e.Button & MouseButtons.Left) == MouseButtons.Left) { ActiveScriptIndex = -1; return; } else if ((e.Button & MouseButtons.Right) == MouseButtons.Right) { cmsScriptMenu.Show(this, PointToClient(Cursor.Position)); return; } } else if ((e.Button & MouseButtons.Left) == MouseButtons.Left && ScriptLink != null) { FinishLinkingScript(S, MouseRec); } else if ((e.Button & MouseButtons.Right) == MouseButtons.Right) { UnlinkScript(S, MouseRec); } } #endregion ScriptLink = null; ScriptLinkIndex = -1; ScriptLinkEventIndex = -1; ScriptLinkType = ScriptLinkTypes.None; ActiveScriptIndex = -1; DrawScripts(); }
public void LaunchButt(GameObject targetCar) { location = targetCar.transform.position; transform.position = location; if (AIScript = targetCar.gameObject.GetComponent <AIController>()) { currentWaypoint = AIScript.GetCurrentWaypointInt(); AIScript.currentPowerup = null; } if (CarScript = targetCar.gameObject.GetComponent <CarController>()) { currentWaypoint = CarScript.GetCurrentWaypointInt(); CarScript.currentPowerup = null; } }
public virtual void Start() { aiScript = FindObjectOfType <AIScript>(); buttons = new RectTransform[transform.childCount]; for (int i = 1; i <= 3; i++) { buttons[i] = transform.GetChild(i).GetComponent <RectTransform>(); int diff = i; buttons[i].GetComponent <Button>().onClick.AddListener(() => { SetDifficultyTo(diff); }); } SelectButton(2, false); }
protected override void Enable() { if (!AIScript.shootLayerEnabled) { return; } if (!CanPlay()) { return; } base.Enable(); AIScript.Shoot(); }
void StartCrime() { perpetrator = SelectPerpetrator (); perpScript = perpetrator.GetComponent<AIScript> (); perpScript.CommitCrime (gameObject.transform.position, gameObject.GetComponent<CrimeSceneScript>()); }
public override void itemPicked(AIScript player) { base.itemPicked(player); player.pickupItem(getWeapon()); }
public virtual void itemPicked(AIScript player) { GameObject.Destroy(itemMesh); itemMesh = null; lastSpawn = Time.time; }