Hunter.Start C# (CSharp) Method

Start() public method

public Start ( ) : void
return void
    void Start()
    {
        //spottedCue = GameObject.Find("SpottedIndicator");  // BUGGED NULL REFERENCE
        anim = this.GetComponent<Animator>();
        leftEndPath = GameObject.Find("LeftWall").transform.position.x;
        rightEndPath = GameObject.Find("RightWall").transform.position.x;

        //set player to the object with tag "Player"
        player = GameObject.FindWithTag("Player").GetComponent<PlayerControl>();

        //Get Position
        originalPosition = this.transform.position;
        originalRotation = this.transform.rotation;

        // Initialize player distance
        playerDistance = new Vector2(0f, 0f);

        //retry restarts movement
        //speed = 5.0f;

        audioHandler = GameObject.FindGameObjectWithTag("AudioHandler").GetComponent<AudioHandlerScript>();
        //speed = defaultSpeed;
        sfx = this.GetComponent<AudioSource>();
        //set volume to player's setting
        sfx.volume = audioHandler.sfxVolume;//PlayerPrefs.GetFloat("SFX");
        if (player.transform.position.x < gameObject.transform.position.x)
        {
            FlipEnemy();
        }

        // set lineOfSight to this objects LineRenderer component and positions
        //lineOfSight = GetComponent<LineRenderer>();
        //lineOfSight.SetPosition(1, new Vector2(lineCastDistance, 0));

        // Initialize camera
        cam = GameObject.FindGameObjectWithTag ("MainCamera");
        camTransform = cam.GetComponent<Transform> ();
    }

Usage Example

Example #1
0
        public Form1()
        {
            InitializeComponent();

            int x = rand.Next(0, 9); int y = rand.Next(0, 9);

            map.DrawMap(map1);
            state = map.GetMap();
            player.Start(state[x, y], hunter.Images[2]);
            map.Generate_Obstacle(4, 4, 4, x, y);

            foreach (Button e in state)
            {
                e.BackColor = Color.Black;
                // e.KeyDown += Button1_KeyDown;
                e.Enabled = false;
            }

            map.UpdateMap(state[x, y], tbstatus, Keys.Q, score, false, player.Get_Score());
            score.Text    = "Score: " + player.Get_Score();
            pr            = new Process(player);
            VISITED_ROOMS = 0;
            label1.Text   = "MAXIMUM ROOMS: " + MAX_ROOMS;
            label3.Text   = "VISITED ROOMS: " + VISITED_ROOMS;
        }