Example #1
0
 public Action(OzHuman oz, float duration)
 {
     this.oz       = oz;
     this.duration = duration;
     beginningTime = Time.time;
     lastTime      = beginningTime;
 }
Example #2
0
File: OzAI.cs Project: lumiknit/mc4
 public override void Step(OzAI ai, OzHuman human)
 {
     if (!HasAction())
     {
         RowFront();
     }
 }
Example #3
0
File: OzAI.cs Project: lumiknit/mc4
        public override void Step(OzAI ai, OzHuman human)
        {
            Debug.Log("Seeking");
            var sight   = human.transform.rotation * new Vector3(0f, 0f, 1f);
            var objects = GameObject.FindGameObjectsWithTag("Player");

            foreach (var obj in objects)
            {
                var h = obj.transform.Find("human2a");
                var d = h.position - human.transform.position;
                if (d.magnitude < 15f && Vector3.Dot(sight, d) > 0f)
                {
                    ChangeAI(new ChasingAI1(h.GetComponent <OzHuman>()));
                    return;
                }
            }
            if (human.rigid.velocity.magnitude < targetVelo)
            {
                RowFront();
                PauseFor(1f);
                targetDir = Random.Range(0, 2);
            }
            else
            {
                if (targetDir == 0)
                {
                    RowLeft();
                }
                else
                {
                    RowRight();
                }
                PauseFor(0.4f);
            }
        }
Example #4
0
File: OzAI.cs Project: lumiknit/mc4
    // Start is called before the first frame update
    void Start()
    {
        humanObject = transform.Find("human2a").gameObject;
        human       = humanObject.GetComponent <OzHuman>();

        switch (Random.Range(0, 6))
        {
        case 0:
            ai = new WanderingAI1();
            break;

        case 1:
            ai = new WanderingAI2();
            break;

        case 2:
            ai = new ChasingAI1(GameObject.Find("Oz").transform.Find("human2a").GetComponent <OzHuman>());
            break;

        case 3:
            ai = new ChasingAI2(GameObject.Find("Oz").transform.Find("human2a").GetComponent <OzHuman>());
            break;

        case 4:
            ai = new SeekingAI1();
            break;

        case 5:
            ai = new NpcKillerAI();
            break;
        }
    }
Example #5
0
File: OzAI.cs Project: lumiknit/mc4
 public void RunStep(OzAI ai, OzHuman human)
 {
     actionTimer -= Time.deltaTime;
     this.ai      = ai;
     this.human   = human;
     if (actionTimer < 0)
     {
         Step(ai, human);
     }
 }
Example #6
0
    // Start is called before the first frame update
    void Start()
    {
        playerOz = GameObject.Find("Oz").transform.Find("human2a").GetComponent <OzHuman>();

        for (int i = 0; i < 30; i++)
        {
            Vector3 p = new Vector3(Random.Range(-200f, 200f), 0.2f, Random.Range(-200f, 200f));
            Instantiate(ozAI, p, Quaternion.Euler(0, Random.Range(0f, 360f), 0));
        }
    }
Example #7
0
File: OzAI.cs Project: lumiknit/mc4
        public override void Step(OzAI ai, OzHuman human)
        {
            if (target == null)
            {
                return;
            }
            if (target.lassitude)
            {
                ChangeAI(new SeekingAI1());
                return;
            }
            Debug.Log("Chasing");
            var d     = target.gameObject.transform.position - human.transform.position;
            var v     = d.normalized;
            var w     = human.transform.rotation * new Vector3(0, 0, 1);
            var dot   = Vector3.Dot(v, w);
            var cross = Vector3.Cross(v, w).y;

            //Debug.Log("d = " + d);
            if (d.magnitude < 6f && cross < 0 && dot > 0)
            {
                HSwing();
                PauseFor(1f);
            }
            else if (human.rigid.velocity.magnitude < 2f)
            {
                RowFront();
                PauseFor(1f);
            }
            else
            {
                if (dot >= 0.9f)
                {
                    RowFront();
                    PauseFor(0.8f);
                }
                else if (cross > 0.1)
                {
                    RowLeft();
                    PauseFor(0.3f);
                }
                else
                {
                    RowRight();
                    PauseFor(0.3f);
                }
            }
        }
Example #8
0
File: OzAI.cs Project: lumiknit/mc4
        public override void Step(OzAI ai, OzHuman human)
        {
            if (target == null)
            {
                PauseFor(5.0f);
                target = GameObject.FindGameObjectsWithTag("NPC")[0];
            }

            var d     = target.transform.position - human.transform.position;
            var v     = d.normalized;
            var w     = human.transform.rotation * new Vector3(0, 0, 1);
            var dot   = Vector3.Dot(v, w);
            var cross = Vector3.Cross(v, w).y;

            //Debug.Log("d = " + d);
            if (d.magnitude < 5f && cross < 0 && dot > 0)
            {
                HSwing();
                PauseFor(1f);
            }
            else if (human.rigid.velocity.magnitude < 2f)
            {
                RowFront();
                PauseFor(1f);
            }
            else
            {
                if (dot >= 0.9f)
                {
                    RowFront();
                    PauseFor(0.8f);
                }
                else if (cross > 0.1)
                {
                    RowLeft();
                    PauseFor(0.3f);
                }
                else
                {
                    RowRight();
                    PauseFor(0.3f);
                }
            }
        }
Example #9
0
File: OzAI.cs Project: lumiknit/mc4
 public override void Step(OzAI ai, OzHuman human)
 {
     if (human.rigid.velocity.magnitude < targetVelo)
     {
         RowFront();
         PauseFor(1f);
         targetDir = Random.Range(0, 2);
     }
     else
     {
         if (targetDir == 0)
         {
             RowLeft();
         }
         else
         {
             RowRight();
         }
         PauseFor(0.4f);
     }
     targetVelo = Random.Range(5f, 8f);
 }
Example #10
0
    // Start is called before the first frame update
    void Start()
    {
        instance = this;

        bowlSize = 200;

        if (!PlayerPrefs.HasKey("gameCount"))
        {
            PlayerPrefs.SetInt("gameCount", 0);
        }
        gameCount = PlayerPrefs.GetInt("gameCount") + 1;
        PlayerPrefs.SetInt("gameCount", gameCount);

        killCount         = 0;
        gameBeginningTime = Time.time;
        gameEndTime       = float.NaN;
        maxSpeed          = 0f;

        playerOz = GameObject.Find("Oz").transform.Find("human2a").GetComponent <OzHuman>();

        for (int i = 0; i < 30; i++)
        {
            SpawnRowingNPC();
        }

        GetComponent <SpawnRings>().Spawn();
        GetComponent <SpawnSpoon>().Spawn();

        fadeInPanel = GameObject.Find("FadeInPanel");
        var image = fadeInPanel.GetComponent <Image>();
        var text  = fadeInPanel.transform.GetChild(0).GetComponent <Text>();

        image.color = new Color(0f, 0f, 0f, 1f);
        text.color  = new Color(1f, 1f, 1f, 1f);
        text.text   = "O#" + gameCount;
        spawnTimer  = 0f;
    }
Example #11
0
 public TestRowFront(OzHuman oz) : base(oz, DURATION)
 {
 }
Example #12
0
 public TestHSwing1(OzHuman oz) : base(oz, DURATION)
 {
 }
Example #13
0
File: OzAI.cs Project: lumiknit/mc4
 public void SetUp(OzAI ai, OzHuman human)
 {
     this.ai    = ai;
     this.human = human;
 }
Example #14
0
 public TestRowRight(OzHuman oz) : base(oz, DURATION)
 {
 }
Example #15
0
File: OzAI.cs Project: lumiknit/mc4
 public ChasingAI2(OzHuman target)
 {
     this.target = target;
 }
Example #16
0
 public TestRowBack(OzHuman oz) : base(oz, DURATION)
 {
 }
Example #17
0
 public TestRowLeft(OzHuman oz) : base(oz, DURATION)
 {
 }
Example #18
0
File: OzAI.cs Project: lumiknit/mc4
 public abstract void Step(OzAI ai, OzHuman human);
Example #19
0
 public TestAction(OzHuman oz) : base(oz, DURATION)
 {
 }
Example #20
0
 // Start is called before the first frame update
 void Start()
 {
     human   = transform.parent.gameObject;
     ozHuman = human.GetComponent <OzHuman>();
 }