コード例 #1
0
    }//PickAnyFromMenu

    public void OnTriggerEnter2D(Collider2D collision)
    {
        if (collision.tag.ToLower() != "pedestrian")
        {
            return;
        }

        BasicAI pedestrian = collision.GetComponent <BasicAI>();

        if (pedestrian == null)
        {
            return;
        }

        bool isPriceGood = District.Instance.TryAttactByPrice(Recepe.Price);

        if (!isPriceGood)
        {
            Debug.Log("Bad Price!");
            return;
        }

        bool isRecepeGood = District.Instance.TryAttractByRecepe(
            ref Recepe.Brains, ref Recepe.Seasoning, ref Recepe.Drinks);

        if (!isRecepeGood)
        {
            Debug.Log("Bad Recepe!");
            return;
        }

        pedestrian.SetState(BasicAI.StateMachine.standingInLine);
        waitingQueue.Add(pedestrian);
    } //OnTriggerEnter2D
コード例 #2
0
    private void OnTriggerEnter2D(Collider2D collision)
    {
        if (collision.gameObject.tag == "Static Obstacle")
        {
            return;
        }

        var distance = Vector2.Distance(collision.gameObject.transform.position, this.gameObject.transform.position);

        if (collision.gameObject.tag == "Enemy")
        {
            ai = collision.gameObject.GetComponent <BasicAI>();
        }
        else if (collision.gameObject.tag == "Player")
        {
            player = collision.gameObject.GetComponent <PlayerController>();
        }

        DamageRange = ((int)(100 - (distance * 50)));
        if (DamageRange >= 1)
        {
            DealDamage(DamageRange);
        }
        else
        {
            DealDamage(1);
            Debug.Log("damage is negative == " + DamageRange);
        }
    }
コード例 #3
0
    }//Update

    public void RemoveFromWaitQueue(BasicAI pedestrian)
    {
        if (waitingQueue.Contains(pedestrian))
        {
            waitingQueue.Remove(pedestrian);
        }
    }//RemoveFromWaitQueue
コード例 #4
0
    public static void speed()
    {
        GameObject go     = GameObject.Find("Ian");
        BasicAI    script = (BasicAI)go.GetComponent(typeof(BasicAI));

        script.speedUp = true;
    }
コード例 #5
0
 public void Initialize(int index)
 {
     _UIHealth.Initialize(1.0f);
     _UIStamina.Initialize(1.0f);
     _UIHealthNumber.Initialize(_health);
     _UIStaminaNumber.Initialize(_stamina);
     for (int i = 0; i < _meleeAmount; i++)
     {
         CreateMelee((Melee.Target)(i - 1), _meleeSprites[i], (i - 1) * _meleeOffset);
     }
     CreateNoMelee(_meleeAmount * _meleeOffset);
     CreatePotion(_itemOffset, false);
     CreatePotion(_itemOffset, true);
     CreateDisabler(_itemOffset, Debuff.CANNOTHEAD);
     CreateDisabler(_itemOffset, Debuff.CANNOTBODY);
     CreateDisabler(_itemOffset, Debuff.CANNOTLEGS);
     _itemMenu.Initialize(_itemActions);
     Reset();
     _id = index;
     AI  = gameObject.GetComponent <BasicAI>();
     if (AI)
     {
         AI.Initialize(_meleeActions);
     }
 }
コード例 #6
0
    }//ServeClient

    public void CookAndServe()
    {
        List <BasicAI> toRemove = new List <BasicAI>();

        for (int i = 0; i < orderedQueue.Count; i++)
        {
            BasicAI client = orderedQueue[i];
            if (!cooking.ContainsKey(client))
            {
                GameUtils.Utils.WarningMessage(client.name + " has no cooking food?!");
                continue;
            }//if
            Recepe foodOnTheGrill = cooking[client];
            bool   isCooked       = foodOnTheGrill.Cook(Time.deltaTime);
            if (isCooked)
            {
                toRemove.Add(client);
                ServeClient(client, foodOnTheGrill);
            } //if cooked
        }     //for
        foreach (BasicAI served in toRemove)
        {
            if (!cooking.ContainsKey(served))
            {
                continue;
            }
            //Destroy(cooking[served].gameObject);
            cooking.Remove(served);
        } //foreach
    }     //Cook
コード例 #7
0
    public static void chasePlayer()
    {
        GameObject go     = GameObject.Find("Ian");
        BasicAI    script = (BasicAI)go.GetComponent(typeof(BasicAI));

        script.StateMachine = 2;
    }
コード例 #8
0
    // Use this for initialization
    void Start()
    {
        spriteRect      = gameObject.GetComponentInChildren <RectTransform>();
        levelmultiplier = LevelProgression.MasterLevelMultiplier;
        player          = GameObject.FindGameObjectWithTag("Player");
        WeaponContainer = GameObject.FindGameObjectWithTag("WeaponContainer");
        hitOnce         = false;
        sound           = gameObject.GetComponent <AudioSource>();

        //scriptedSwitchWeapons = GameObject.FindGameObjectWithTag("WeaponContainer").GetComponent<SwitchWeapons>();
        //CurrentPlayerWeapon = scriptedSwitchWeapons.weaponZero;
        //weaponstats = CurrentPlayerWeapon.GetComponent<WeaponStats>();
        if (flashwait == 0)
        {
            flashwait = .1f;
        }

        if (levelmultiplier < 1)
        {
            basehealth = UnityEngine.Random.Range(50, 150);
        }
        if (levelmultiplier >= 1)
        {
            basehealth = UnityEngine.Random.Range(50, 150) * levelmultiplier;
        }

        if (levelmultiplier == 0)
        {
            xpvalue = (basehealth / 10);
        }
        if (levelmultiplier >= 1)
        {
            xpvalue = (basehealth / 10) * levelmultiplier;
        }
        score = basehealth * 10;

        dropbuff = Random.Range(1, 101);

        if (gameObject.CompareTag("FloatingEyebot"))
        {
            basehealth = Random.Range(25, 75) * levelmultiplier;
        }
        currenthealth = basehealth;
        music         = GameObject.Find("Music").GetComponent <AudioSource>();

        if (!gameObject.CompareTag("SpinBoss"))
        {
            basicAI = gameObject.GetComponentInChildren <BasicAI>();

            isclipPlaying = basicAI.clipPlaying;
        }

        playerstats          = GameObject.FindGameObjectWithTag("Player").GetComponent <CharacterStats>();
        characterAttackBonus = playerstats.attackBonus;
        xpGiven = false;

        //scaledone = false;
        healthHolder  = this.gameObject.transform.Find("HealthHolder").GetComponent <Transform>();
        originalscale = healthHolder.localScale.x;
    }
コード例 #9
0
 void OnTriggerEnter2D(Collider2D coll)
 {
     if (coll.gameObject.tag == "EnemyVision")
     {
         return;
     }
     if (coll.gameObject.tag == "Player")
     {
         player = coll.gameObject.GetComponent <PlayerController>();
         player.TakeDamage(damage);
         Destroy(this.gameObject);
     }
     else if (coll.gameObject.tag == "Enemy")
     {
         AI = coll.gameObject.GetComponent <BasicAI>();
         AI.TakeDamage(damage);
         Destroy(this.gameObject);
     }
     else if (coll.gameObject.tag == "Bullet" || coll.gameObject.tag == "PlayerBullet" || coll.gameObject.tag == "CanShootOver")
     {
         return;
     }
     else
     {
         Destroy(gameObject);
     }
 }
コード例 #10
0
    }     //Cook

    /// <summary>
    ///  Remove food from the grill for the given client.
    /// </summary>
    /// <param name="ofClient"></param>
    public void DisposeCooked(BasicAI ofClient)
    {
        if (cooking.ContainsKey(ofClient))
        {
            cooking.Remove(ofClient);
        }
    }//DisposeCooked
コード例 #11
0
    public virtual void Start()
    {
        characterAI   = GetComponent <BasicAI>();
        basicMovement = GetComponent <BasicMovement>();
        agent         = GetComponent <NavMeshAgent>();
        originalSpeed = agent.speed;
        anim          = transform.GetChild(0).gameObject.GetComponent <Animator>();
        // Find all waypoitns
        var waypoints = GameObject.FindGameObjectsWithTag("Waypoint");

        // Only add waypoints that are close to the enemy so they don't run across the map.
        foreach (var waypoint in waypoints)
        {
            WaypointTransforms.Add(waypoint.transform);
        }

        var wayPointTransformsToRemove = new List <Transform>();

        // Remove waypoints that are too far away
        foreach (var waypointTransform in WaypointTransforms)
        {
            if (!(Vector3.Distance(waypointTransform.position, transform.position) <= maxWayPointRange) || !WaypointInLOS(waypointTransform))
            {
                wayPointTransformsToRemove.Add(waypointTransform);
            }
        }
        WaypointTransforms.RemoveAll(x => wayPointTransformsToRemove.Contains(x));

        if (WaypointTransforms.Count > 0)
        {
            WaypointTransforms.Sort((a, b) => (Vector3.Distance(a.position, transform.position).CompareTo(Vector3.Distance(b.position, transform.position))));
            IsPatrolling(true);
        }
    }
コード例 #12
0
    // Use this for initialization
    void Start()
    {
        PlayerAIs = new BasicAI[NumberOfPlayer];

        PlayerAIs[0] = new AIPlayer_UtilityAI(); //is human player
        PlayerAIs[1] = new BasicAI();
    }
コード例 #13
0
        public ArtificialIntelligence(UserInterface userInterface, VisualCortex visualCortex)
        {
            if (logicTimer != null)
            {
                logicTimer.Stop();
            }
            // 0 = 40fps when set to 1ms, 8fps screen, 15fps is 7.5fps
            // 1 = 65fps when set to 1ms, 8fps screen, 40fps is 8fps
            // 2 = 1000fps when set to 1ms, 6 fps screen, 60fps is 6.35 fps
            // 3 = 1000fps when set to 1ms, 7.5 fps screen, 60fps is 7.65 fps, 200fps is 8fps
            logicTimer = new ATimer(3, 1, new ATimer.ElapsedTimerDelegate(() => { logic(); }));



            this.userInterface = userInterface;
            this.visualCortex  = visualCortex;

            timerPerformanceStopwatch         = new High_Performance_Timer.Stopwatch();
            screenCapturePerformanceStopWatch = new High_Performance_Timer.Stopwatch();

            basicAI   = new BasicAI();
            autoQueue = new AutoQueueManager();

            logicTimer.Start();
        }
コード例 #14
0
ファイル: BasicAIGUI.cs プロジェクト: TheZenNinja/FantasyGame
    private void OnSceneGUI()
    {
        BasicAI ai = (BasicAI)target;

        Vector3 pos = ai.transform.position;

        Handles.color = Color.red;
        Handles.DrawWireDisc(pos + ai.transform.up, Vector3.up, ai.attackDistance);

        Handles.color = Color.white;
        if (ai.fovLayers.Length > 0)
        {
            foreach (FOV fov in ai.fovLayers)
            {
                if (fov.angle >= 360)
                {
                    Handles.DrawWireDisc(ai.transform.position + ai.transform.up, Vector3.up, fov.distance);
                }
                else
                {
                    Vector3 angleA = ai.DirFromAngle(-fov.angle / 2);
                    Vector3 angleB = ai.DirFromAngle(fov.angle / 2);

                    Handles.DrawWireArc(pos + ai.transform.up, Vector3.up, angleA, fov.angle, fov.distance);

                    Handles.DrawLine(pos + ai.transform.up, pos + ai.transform.up + angleA * fov.distance);
                    Handles.DrawLine(pos + ai.transform.up, pos + ai.transform.up + angleB * fov.distance);
                }
            }
        }
    }
コード例 #15
0
    public static void startPatrol()
    {
        GameObject go     = GameObject.Find("Ian");
        BasicAI    script = (BasicAI)go.GetComponent(typeof(BasicAI));

        script.speedReset   = true;
        script.StateMachine = 1;
    }
コード例 #16
0
ファイル: GameHandler.cs プロジェクト: Harrimaga/LD48
        public GameHandler()
        {
            player1 = new Player(0);
            player2 = new Player(1);

            ai = new BasicAI();
            StartGame();
        }
コード例 #17
0
ファイル: Spawner.cs プロジェクト: brandonLaing/GemTDRedux
    public void SpawnAI(GameObject enemyToSpawn)
    {
        GameObject spawned       = Instantiate(basicAIPrefab, startNode.tileTransform.position + Vector3.up, basicAIPrefab.transform.rotation);
        BasicAI    spawnedScript = spawned.GetComponent <BasicAI>();

        spawnedScript.startNode = startNode;
        spawnedScript.endNode   = endNode;
        spawnedScript.PathThoughMaze();
    }
コード例 #18
0
 // Use this for initialization
 void Start()
 {
     changeAttack  = false;
     attackCount   = 1;
     currentAttack = charge;
     charge        = gameObject.GetComponent <TankChargeAttack>();
     bouncy        = gameObject.GetComponent <BouncyProjectileAttack>();
     moveTowards   = gameObject.GetComponent <BasicAI>();
 }
コード例 #19
0
    }//TakeOrder

    public void ServeClient(BasicAI client, Recepe toServe)
    {
        float cash = client.RecieveOrder(toServe);

        _shopStorage.Cash += cash;
        if (orderedQueue.Contains(client))
        {
            orderedQueue.Remove(client);
        }
    }//ServeClient
コード例 #20
0
ファイル: Tests.cs プロジェクト: DantesFonCake/Game
 public void SetUp()
 {
     game      = new GameModel(levelLines);
     level     = game.CurrentLevel;
     testEnemy = new TestEnemy(game, new Point(1, 1));
     level.PlaceObject(testEnemy);
     ai = new BasicAI(game, new List <BasicEnemy> {
         testEnemy
     });
 }
コード例 #21
0
    // Start is called before the first frame update
    private void Start()
    {
        movement = GetComponent <BasicAI>();
        var temp = GetComponent <Transform>().Find("Text");

        text                = temp.GetComponent <TextMesh>();
        temp                = GetComponent <Transform>().Find("SubText");
        subText             = temp.GetComponent <TextMesh>();
        state               = State.FindingSeat;
        timeLeftStateSwitch = Random.Range(timeStateSwitchMin, timeStateSwitchMax);
        timeLeftToEat       = timeLeftStateSwitch = Random.Range(timeToEatMin, timeToEatMax);
    }
コード例 #22
0
	void Awake(){
		myState = this.gameObject.GetComponent<AbstractEntity>();
		ai = this.gameObject.GetComponent<BasicAI>();
		set(myState.getMAXHP(),myState.getMAXMP(),myState.getHP(),myState.getMP(),leftX,topY,width,height);
		
		
		// animation
		timeLeftAnimationChange = timeBetweenAnimation;
		animationHealthForward = true;
		animationManaForward = false;
		animationHealthIndex = 0;
		animationManaIndex = 0;
	}
コード例 #23
0
        public void Play()
        {
            AI = new BasicAI(_mainPage.EnemyCellsList(), _mainPage.EnemyBoard());
            bool gameOverFlag = false;

            while (!gameOverFlag)
            {
                gameOverFlag = _mainPage.IsGameOver();
                _mainPage.WaitForStrike();
                AI.StrikeCell();
                Console.WriteLine(_mainPage.GetFinalNotification());
            }
        }
コード例 #24
0
    //ReactToHit() is called in the RayShooter script once a GameObject with the Reactive Target script has been hit
    public void ReactToHit()
    {
        //Stops the BasicWanderingAI script
        //Enemys would still walk around after they got shot if SetDead wasnt set to true
        BasicAI behavior = GetComponent <BasicAI>();

        if (behavior != null)
        {
            // behavior.SetDead(true);
        }
        //After the GameObject is hit it can die
        StartCoroutine(Die());
    }
コード例 #25
0
    private void Awake()
    {
        ai               = GetComponent <BasicAI>();
        Target           = ai.target;
        MaxHealth        = health;
        enemyRenderer    = GetComponentInChildren <Renderer>();
        originalMaterial = enemyRenderer.material;

        attackTimer        = timeBetweenAttacks * 0.5f;
        TimeBetweenAttacks = timeBetweenAttacks;
        EnemyAudioSource   = GetComponent <AudioSource>();
        GamesManager       = GameObject.FindWithTag("GameManagement").GetComponent <GameManagement>();
    }
コード例 #26
0
 void OnTriggerEnter2D(Collider2D coll)
 {
     if (coll.gameObject.tag == "Enemy" && attacker != "enemy")
     {
         BasicAI ai = coll.gameObject.GetComponent <BasicAI>();
         ai.TakeDamage(damage);
     }
     if (coll.gameObject.tag == "Player" && attacker == "enemy")
     {
         player.PlayerController Player = coll.gameObject.GetComponent <player.PlayerController>();
         Player.TakeDamage(damage);
         Debug.Log(damage);
     }
 }
コード例 #27
0
    // public float distance;

    // Use this for initialization
    void Start()
    {
        AI    = gameObject.GetComponent <BasicAI>();
        agent = gameObject.GetComponent <NavMeshAgent>();
        anim  = gameObject.GetComponent <Animator>();
        if (gameObject.GetComponentInChildren <SpriteLookAt>())
        {
            spritelookat = gameObject.GetComponentInChildren <SpriteLookAt>();
        }
        rends = gameObject.GetComponentsInChildren <Renderer>();
        colls = gameObject.GetComponentsInChildren <Collider>();
        StartCoroutine(Disappear());
        rb = gameObject.GetComponent <Rigidbody>();
        //StartCoroutine(Disappear());
    }
コード例 #28
0
ファイル: Character.cs プロジェクト: qxc/Blink
 private void OnCollisionStay2D(Collision2D collision)
 {
     if (collision.gameObject.tag == "AICharacter" && isMelee)
     {
         //Debug.Log("AI & IsMelee");
         BasicAI ai = collision.gameObject.GetComponent <BasicAI>();
         if (!ai.meleeDamaged)
         {
             ai.Damage(meleeDamage);
             isInvulnerable = true;
             gameObject.GetComponent <Renderer>().material.color = new Color(1, 1, 1, invulnerableTransparency);
             Invoke("TurnOffInvulnerable", invulnerablePeriod);
         }
         ai.meleeDamaged = true;
     }
 }
コード例 #29
0
ファイル: EnemySpawner.cs プロジェクト: KasJeg/DungeonMaster
    // Update is called once per frame
    void Update()
    {
        if (Player == null)
        {
            Player = GameObject.FindGameObjectWithTag("Player");
        }


        if (Enabled == false)
        {
            return;
        }

        if (HowManyEnemiesToSpawn <= 0)
        {
            if (areAllDead() == true)
            {
                Debug.Log("Everyone is ded");
                //shopController.alldead();
            }
        }

        else if (Time.time > _nextSpawn)
        {
            if (Player == null)
            {
                return;
            }
            Transform currentSpawner = getRandomSpawnLocation();



            HowManyEnemiesToSpawn--;
            _nextSpawn = Time.time + SecondsToSpawnAnotherEnemy;
            GameObject enemyInstance = Instantiate(Enemy, currentSpawner.position, currentSpawner.rotation) as GameObject;
            BasicAI    aiScript      = enemyInstance.GetComponent <BasicAI>();
            aiScript.target     = Player.transform;
            aiScript._following = true;

            foreach (object enemy in GameObject.FindGameObjectsWithTag("Enemy"))
            {
                i++;
            }
            i = 0;
        }
    }
コード例 #30
0
    private void OnValidate()
    {
        if (_creature == null)
        {
            _creature = GetComponentInParent <Creature>();
        }

        if (_ai == null)
        {
            _ai = GetComponentInParent <BasicAI>();
        }

        if (_shouldUpdate)
        {
            UpdateFOVMesh();
        }
    }
コード例 #31
0
ファイル: Character.cs プロジェクト: qxc/Blink
    private void OnTriggerEnter2D(Collider2D collision)
    {
        //Debug.Log(collision.name);
        if (collision.tag == "AIProjectile")
        {
            if (!isInvulnerable && collision.gameObject.GetComponent <Projectile>().hasTarget)
            {
                //Debug.Log("Invulnerable");
                Destroy(collision.gameObject);
                //if (!isMelee)
                //{
                //Debug.Log("Hit by " + collision.name);
                life--;
                if (life <= 0)
                {
                    RestartGame();
                }
                //}
            }
            else if (isInvulnerable)
            {
                Destroy(collision.gameObject);
            }
        }

        /*
         * Debug.Log("Collided");
         * Debug.Log(isMelee);
         * Debug.Log(collision.gameObject.tag);
         */
        if (collision.gameObject.tag == "AICharacter" && isMelee)
        {
            //Debug.Log("AI & IsMelee");
            BasicAI ai = collision.gameObject.GetComponent <BasicAI>();
            if (!ai.meleeDamaged)
            {
                ai.Damage(meleeDamage);
            }
            ai.meleeDamaged = true;
        }
    }