Example #1
0
 // Use this for initialization
 void Start()
 {
     map = GameObject.FindGameObjectWithTag("Map").GetComponent<Map>();
     animator = GetComponent<Animator>();
     gridMove = GetComponent<GridMove>();
     weapon = GetComponent<Weapon>();
 }
Example #2
0
 // Start is called before the first frame update
 void Start()
 {
     gridMove = GetComponent <GridMove>();
     controls = new Controls();
     controls.Player.SetCallbacks(this);
     controls.Player.Enable();
 }
Example #3
0
 public void Start()
 {
     InitPos.x            = transform.position.x;
     InitPos.y            = transform.position.y;
     nameOfThisGameObject = transform.name;
     gridmove             = GameObject.FindGameObjectWithTag("Character").GetComponent <GridMove> ();
 }
Example #4
0
    GridPosition GetMove(GridPosition from, GridPosition to)
    {
        HashSet <GridPosition> visited = new HashSet <GridPosition>();
        Queue <GridMove>       moves   = new Queue <GridMove>();

        visited.Add(from);
        AddBaseMove(moves, new GridPosition(from.x + 1, from.y), visited);
        AddBaseMove(moves, new GridPosition(from.x - 1, from.y), visited);
        AddBaseMove(moves, new GridPosition(from.x, from.y + 1), visited);
        AddBaseMove(moves, new GridPosition(from.x, from.y - 1), visited);

        while (moves.Count > 0)
        {
            GridMove current = moves.Dequeue();
            visited.Add(current.endPoint);
            if (current.endPoint == to)
            {
                // since we're exploring in breadth-first order, the path we find first is the best possible.
                return(current.firstStep);
            }

            AddMove(moves, current.firstStep, new GridPosition(current.endPoint.x + 1, current.endPoint.y), visited);
            AddMove(moves, current.firstStep, new GridPosition(current.endPoint.x - 1, current.endPoint.y), visited);
            AddMove(moves, current.firstStep, new GridPosition(current.endPoint.x, current.endPoint.y + 1), visited);
            AddMove(moves, current.firstStep, new GridPosition(current.endPoint.x, current.endPoint.y - 1), visited);
        }

        // if we failed to find a path, I have no idea what's happening... give up? Signal this failure somehow?
        return(from);
    }
    // Use this for initialization
    void Start()
    {
        gridMove = GetComponent <GridMove>();
        animator = GetComponent <Animator>();

        gameController = GameObject.FindGameObjectWithTag("GameController");

        player = GameObject.FindGameObjectWithTag("Player").transform;
    }
    void    Awake()
    {
        // 사용할 Object를 캐시.
        m_grid_move = GetComponent <GridMove>();
        m_gameCtrl  = FindObjectOfType(typeof(GameCtrl)) as GameCtrl;
        m_weapon    = GetComponent <Weapon>();
        m_map       = FindObjectOfType(typeof(Map)) as Map;

        m_gameCtrl.AddObjectToList(gameObject);

        m_audio_channels = FindObjectOfType(typeof(AudioChannels)) as AudioChannels;
    }
Example #7
0
    // Use this for initialization
    void    Awake()
    {
        m_grid_move = GetComponent <GridMove>();
        m_gameCtrl  = FindObjectOfType(typeof(GameCtrl)) as GameCtrl;
        m_gameCtrl.AddObjectToList(gameObject);
        m_audio = FindObjectOfType(typeof(AudioChannels)) as AudioChannels;

        m_animator = GetComponent <Animator>();

        if (m_animator == null)
        {
            Debug.LogError("Can't find Animator component.");
        }
    }
Example #8
0
    void OnCollisionEnter2D(Collision2D col)
    {
        if (col.gameObject.tag.Equals("Player"))
        {
            Debug.Log("Player Died");
            Animator anim = GetComponent <Animator>();
            this.gameObject.GetComponent <Renderer>().enabled = true;
            GridMove player = col.gameObject.GetComponent <GridMove>();
            anim.transform.position = player.getObjectivePosition();
            anim.transform.rotation = col.gameObject.transform.rotation;


            anim_wall.SetBool("DeathWall", true);
            col.gameObject.GetComponent <GridMove>().setIsDead(true);
            col.gameObject.GetComponent <SpriteRenderer>().enabled = false;

            col.gameObject.GetComponent <PlayerDeath>().Kill(1, GameManager.deathTypes.Spikes);

            //Instantiate(spikes,this.transform.position,this.transform.rotation);
        }
    }
 // Use this for initialization
 void Start()
 {
     m_grid_move = GetComponent<GridMove> ();
 }
Example #10
0
 private void Start()
 {
     gridMove = GetComponent <GridMove>();
 }