Beispiel #1
0
    public void Start()
    {
        dest = GetComponent <Pathfinding.AIDestinationSetter>();
        ai   = GetComponent <Pathfinding.IAstarAI>();
        int rando = Random.Range(0, plants.Length - 1);

        while (plants[rando].IsOccupied())
        {
            rando = Random.Range(0, plants.Length - 1);
        }
        growth = plants[rando];
        growth.MakeOccupied();
        original = growth.point.transform;
        for (int i = 0; i < plants.Length; i++)
        {
            if (plants[i].IsReady())
            {
                original = plants[i].point.transform;
                growth   = plants[i];
                growth.MakeOccupied();
            }
        }
        dest.target  = original;
        dest.enabled = true;
    }
Beispiel #2
0
    private void Start()
    {
        photonview = this.transform.GetChild(0).GetComponent <PhotonView>();

        PlayerObj.SetActive(true);
        //rvocontroller = GetComponentInChildren<Pathfinding.RVO.RVOController>();
        seeker             = GetComponentInChildren <Pathfinding.Seeker>();
        aipath             = GetComponentInChildren <Pathfinding.AIPath>();
        funnelmodifier     = GetComponentInChildren <Pathfinding.FunnelModifier>();
        aidestinatonsetter = GetComponentInChildren <Pathfinding.AIDestinationSetter>();
        playermouse        = GetComponentInChildren <PlayerMouse>();
        rigidbody          = GetComponentInChildren <Rigidbody>();
        WarFog             = PlayerObj.GetComponent <FogOfWarEntity>();
        forminimap         = transform.GetChild(2).gameObject;
        astar_target       = transform.GetChild(1).gameObject;
        splatmanager       = transform.GetChild(0).GetChild(0).gameObject;

        rigidbody.isKinematic = true;
        WarFog.enabled        = false;

        if (photonView.isMine)
        {
            PlayerObj.name = gameObject.name + "_" + PhotonNetwork.player.NickName;
        }
        else
        {
            PlayerObj.name = gameObject.name + photonView.owner.NickName;
        }

        SceneManager.activeSceneChanged += SceneLoaded;

        DontDestroyOnLoad(this);
    }
Beispiel #3
0
    // Use this for initialization
    void Awake()
    {
        destSetter      = GetComponent <Pathfinding.AIDestinationSetter>();
        destLerp        = GetComponent <Pathfinding.AILerp>();
        player          = GameObject.Find("Player");
        curseController = GameObject.Find("CurseController").GetComponent <CurseController>();

        enemyTransform   = GetComponent <Transform>();
        enemyBoxCollider = GetComponent <BoxCollider2D>();
        stats            = GetComponent <ObjectStats>();
        moveScript       = GetComponent <MoveObject>();
        moveConf         = GetComponent <MoveConfirmation>();

        gameCamera = GameObject.Find("Main Camera").GetComponent <CameraController>();

        enemyHealthBar     = this.transform.Find("ObjectCanvas").transform.Find("EnemyHealthBar").gameObject.GetComponent <RectTransform>();
        enemyCanvas        = this.transform.Find("ObjectCanvas").gameObject;
        healthBarMaxWidth  = enemyHealthBar.rect.width;
        healthBarCurrWidth = healthBarMaxWidth;

        spriteRender = GetComponent <SpriteRenderer>();

        stunned = false;


        InitializeValues();

        destSetter.target = player.transform;

        wallLayer = 8;
    }
 // Use this for initialization
 void Start()
 {
     ai                      = GetComponent <IAstarAI>();
     naughtyBoy              = GameObject.Find("Ghost");
     uncleGhostTarget        = GetComponent <Pathfinding.AIDestinationSetter>();
     uncleGhostTarget.target = naughtyBoy.transform;
 }
Beispiel #5
0
    private void Awake()
    {
        myPhotonView = GetComponent <PhotonView>();
        if (photonView.isMine)
        {
            championName = PlayerData.Instance.championName;
            if (championName.Contains("Mundo"))
            {
                isNoMP = true;
            }
            SetSpell();
            SetStatSkill(championName);

            item = PlayerData.Instance.item;
        }
        else
        {
            item = new int[6];
        }
        totalStat = myStat.ClassCopy();

        myAIDestinationSetter = GetComponent <Pathfinding.AIDestinationSetter>();
        myAnimator            = GetComponent <Animator>();
        theAIPath             = GetComponent <AIPath>();
        playerSpell           = GetComponent <PlayerSpell>();
        playerData            = PlayerData.Instance;
        audioSource           = GetComponent <AudioSource>();

        int ran = Random.Range(1, 9);

        redPos  = new Vector3(4 + ran, 0.5f, 10f);
        bluePos = new Vector3(262 + ran, 0.5f, 270f);
    }
Beispiel #6
0
 void Start()
 {
     lerp          = GetComponent <AILerp>();
     findMe        = GetComponent <AIDestinationSetter>();
     state         = DogState.DEFAULT;
     player        = GameObject.FindGameObjectWithTag("Player");
     findMe.target = player.transform;
 }
Beispiel #7
0
 public void findCrow()
 {
     crow            = GameObject.FindWithTag("Crow");
     crowScript      = crow.GetComponentInChildren <CrowFlyScript>();
     targetingScript = crow.GetComponentInParent <Pathfinding.AIDestinationSetter>();
     crowBody        = crow.GetComponentInParent <Rigidbody2D>();
     crowParent      = crow.transform.parent.transform;
 }
    IEnumerator LateStart()
    {
        yield return(new WaitForSeconds(0.5f));

        Pathfinding.AIDestinationSetter ai_destination = this.GetComponent <Pathfinding.AIDestinationSetter>();
        target     = ai_destination.target;
        ai_star    = this.GetComponent <Pathfinding.IAstarAI>();
        base_speed = ai_star.maxSpeed;
    }
Beispiel #9
0
 void Start()
 {
     dead         = false;
     trig         = GameObject.Find("Trigger");
     self         = gameObject;
     sinBin       = GameObject.Find("sinBin");
     aides        = GetComponent <Pathfinding.AIDestinationSetter>();
     target       = aides.target;
     playerScript = target.GetComponent <EndCondition>();
 }
Beispiel #10
0
    public override void Start()
    {
        base.Start();
        pathfinding = GetComponent <Pathfinding.AIDestinationSetter>();
        InvokeRepeating("FindClosestTreasure", 0f, 3f);



        CurrentHealth = MaxHealth;
        PlayerPrefs.SetInt("playerHP", CurrentHealth);
        audioPlayer = gameObject.GetComponent <AudioSource>();
    }
    private void Awake()
    {
        Enemy_AI = GetComponent <Pathfinding.AIPath>();
        HealthBar_UI.InitializeHealth(health);
        Random_X_Velocity = Mathf.Sign(Random.Range(-1f, 1f)) * Random.RandomRange(0.1f, 2f);        // random direction and magnitude.

        Rat_Anim = GetComponent <Animator>();
        if (Gigantamax)
        {
            Target      = GetComponent <Pathfinding.AIDestinationSetter>();
            totalHealth = health;
        }
    }
Beispiel #12
0
 // Update is called once per frame
 void Update()
 {
     enemies = GameObject.FindGameObjectsWithTag("Enemy");
     if (enemies.Length < 6)
     {
         int x = Random.Range(0, location.Length);
         spawnLocation = location[x];                                                                            // select random spawn location from list of spawns
         Rigidbody clone;
         clone         = Instantiate(enemy, spawnLocation.transform.position, spawnLocation.transform.rotation); // spawn enemy
         target        = clone.GetComponent <Pathfinding.AIDestinationSetter>();
         target.target = player.transform;                                                                       // set path finding target to player
     }
 }
Beispiel #13
0
    // Start is called before the first frame update
    void Start()
    {
        TankMovement[] players    = FindObjectsOfType <TankMovement>();
        TankMovement   player1    = players[0];
        TankMovement   player2    = players[1];
        Transform      direction1 = player1.transform;
        Transform      direction2 = player1.transform;

        // Instantiate at position (0, 0, 0) and zero rotation.
        clone = Instantiate(myPrefab, SpawnPosition.transform.position, Quaternion.identity);
        Pathfinding.AIDestinationSetter player_target = clone.GetComponent <Pathfinding.AIDestinationSetter>();
        player_target.target = direction2;
    }
Beispiel #14
0
    // Start is called before the first frame update
    void Start()
    {
        playerCrowScript       = GameObject.FindWithTag("Player").GetComponent <Player_to_Crow>();
        targetingScript        = GetComponentInParent <Pathfinding.AIDestinationSetter>();
        targetingScript.target = playerCrowScript.returnCrowTarget1();

        crowParent.transform.position = playerCrowScript.returnCrowTarget1().position;

        crow_Animation = GetComponent <Animator>();
        AnimatorStateInfo state = crow_Animation.GetCurrentAnimatorStateInfo(0);

        crow_Animation.Play(state.fullPathHash, -1, Random.Range(0f, 1f));
        ai_path = GetComponentInParent <Pathfinding.AIPath>();
    }
Beispiel #15
0
    private void Awake()
    {
        target         = new GameObject("Target");
        rb             = GetComponent <Rigidbody2D>();
        NPCPath        = GetComponent <Pathfinding.AIPath>();
        NPCDestination = GetComponent <Pathfinding.AIDestinationSetter>();
        ghost          = GameObject.Find("Ghost");

        shouts = GetComponents <AudioSource>();

        EventManager.AddListener(EventTypes.RunawayToDoorNew, Runaway);
        EventManager.AddListener(EventTypes.RunawayAnywhere, Investigate);
        //EventManager.AddListener(EventTypes.StopRunaway, RunToDoor);
        EventManager.AddListener(EventTypes.StopRunawayAnywhere, StopInvestigation);
        //EventManager.AddListener(EventTypes.RunToDoor, RunToDoor);
        EventManager.AddListener(EventTypes.Dead, OnDeath);
    }
    void BotSpawn(int i)
    {
        bot = Instantiate(botPrefab);
        bot.transform.position = RandomPos();
        bot.transform.SetParent(transform);
        bot.transform.eulerAngles = new Vector3(0, Random.Range(0, 360), 0);
        botList.Add(bot.transform);

        nameText = Instantiate(nameTextPrefab);
        nameText.transform.SetParent(namesParent);
        nameText.GetComponent <NameText>().target = bot.transform;
        nameText.GetComponent <TextMesh>().text   = names[i];

        bot.GetComponent <Renderer>().material.color = colorList[Random.Range(0, colorList.Count)];
        bot.name = names[i];
        Pathfinding.AIDestinationSetter a = bot.GetComponent <Pathfinding.AIDestinationSetter>();
        a.killData = new KillData(bot.name, 0);
        gameController.killList.Add(a.killData);
    }
Beispiel #17
0
    void Awake()
    {
        base.Awake();
        //initialize child specific variables
        visionRadius = 5f;

        //get references to all attatched hitboxes and set the default
        Hitboxes = new List <BoxCollider2D>();
        Transform[] ts = GetComponentsInChildren <Transform>();
        foreach (Transform t in ts)
        {
            if (t.CompareTag("Hitbox"))
            {
                Hitboxes.Add(t.GetComponent <BoxCollider2D>());
            }
        }

        effectiveHitbox = Hitboxes[0];

        Path = GetComponent <Pathfinding.AIPath>();
        DestinationSetter = GetComponent <Pathfinding.AIDestinationSetter>();
        AIPatrol          = GetComponent <Pathfinding.Patrol>();

        Path.maxSpeed = movementSpeed;

        currentAIState  = AIState.idle;
        previousAIState = AIState.start;

        //TG
        //I am not searching on instantiation
        bIsSearching = false;
        bIsFleeing   = false;
        bIsCounting  = false;

        //Create chase waypoint
        chaseTarget = Instantiate(waypoint, gameObject.transform.position, new Quaternion(), GameObject.Find("waypointListContainer").transform);

        //Create patrol waypoints
        patrolPointArray[0] = Instantiate(waypoint, new Vector3(gameObject.transform.position.x + 5f, gameObject.transform.position.y + 5f, 0), new Quaternion(), GameObject.Find("waypointListContainer").transform);
        patrolPointArray[1] = Instantiate(waypoint, new Vector3(gameObject.transform.position.x + 5f, gameObject.transform.position.y - 5f, 0), new Quaternion(), GameObject.Find("waypointListContainer").transform);
        patrolPointArray[2] = Instantiate(waypoint, new Vector3(gameObject.transform.position.x - 5f, gameObject.transform.position.y + 5f, 0), new Quaternion(), GameObject.Find("waypointListContainer").transform);
        patrolPointArray[3] = Instantiate(waypoint, new Vector3(gameObject.transform.position.x - 5f, gameObject.transform.position.y - 5f, 0), new Quaternion(), GameObject.Find("waypointListContainer").transform);
    }
Beispiel #18
0
    void Start()
    {
        cam             = Camera.main;
        rb              = GetComponent <Rigidbody2D>();
        stats           = GetComponent <BasicStats>();
        headReset       = transform.Find("Head Reset");
        audioManager    = AudioManager.instance;
        animTimeManager = GameManager.instance.GetComponent <AnimTimeManager>();
        gm              = GameManager.instance;
        anim            = GetComponent <Animator>();
        obstacleMask    = LayerMask.GetMask("Walls", "OpenDoors", "ClosedDoors");

        AIDestSetter  = GetComponent <Pathfinding.AIDestinationSetter>();
        AIPath        = GetComponent <Pathfinding.AIPath>();
        RVOController = GetComponent <Pathfinding.RVO.RVOController>();

        CalculateMoveSpeeds();

        StartCoroutine(UpdateFootstepSounds());
    }