コード例 #1
0
    List <IntVector2D> PlanPathToLocForAvatar(IntVector2D goalPos, Char2D avatar, bool sendThereIfPossible)
    {
        List <IntVector2D> list        = null;
        PlaneOrientation   orientation = avatar.Orientation;

        if (WorldManager.g.IsInBounds2D(goalPos, orientation))
        {
            IntVector2D lastLoc = avatar.Location;
            list = WorldManager.g.PlanPath(avatar, lastLoc, goalPos);
            if (list != null)
            {
                for (int i = list.Count - 1; i >= 0; i--)
                {
                    IntVector2D nextLoc = list[i];
                    Vector3     a       = WorldManager.g.WorldPosFromIntVec(lastLoc, orientation);
                    Vector3     b       = WorldManager.g.WorldPosFromIntVec(nextLoc, orientation);
                    Debug.DrawLine(a, b, Color.red);
                    lastLoc = nextLoc;
                }
                if (sendThereIfPossible)
                {
                    avatar.DesiredPath = list;
                }
            }
            else
            {
                // Debug.Log("NO VALID PATH FOR "+orientation.ToString()+"!");
            }
        }
        return(list);
    }
コード例 #2
0
ファイル: WorldManager.cs プロジェクト: jceipek/Dissonance
    // Adapted From http://stackoverflow.com/questions/10983110/a-star-a-and-generic-find-method
    public List <IntVector2D> PlanPath(Char2D entity, IntVector2D start, IntVector2D destination)
    {
        PlaneOrientation   orientation       = entity.Orientation;
        List <IntVector2D> relativeLocations = entity.AbsoluteLocations(new IntVector2D(0, 0));
        var closed = new HashSet <IntVector2D>();
        var queue  = new PriorityQueue <Path <IntVector2D>, float>();

        queue.Enqueue(new Path <IntVector2D>(start), 0f);
        while (!queue.IsEmpty)
        {
            var path = queue.Dequeue();
            if (closed.Contains(path.LastStep))
            {
                continue;
            }
            if (path.LastStep == destination)
            {
                return(path.AsList);
            }
            IntVector2D leafNode = path.LastStep;
            closed.Add(leafNode);
            List <IntVector2D> neighbors = ConnectedNodesForRelativeLocations(relativeLocations, leafNode, orientation);
            for (int i = 0; i < neighbors.Count; i++)
            {
                IntVector2D n        = neighbors[i];
                float       stepCost = CostBetween(path.LastStep, n);
                var         newPath  = path.AddStep(n, stepCost);
                queue.Enqueue(newPath, newPath.TotalCost + HeuristicCostEstimate(n, destination));
            }
        }
        return(null);
    }
コード例 #3
0
    public void Init(GameObject player)
    {
        Hideall();

        Show("Ui_play", true);

        GameObject ui     = null;
        Ui_base    uiBase = null;

        for (int i = 0; i < _uiList.Length; i++)
        {
            ui     = _uiList[i];
            uiBase = ui.GetComponent <Ui_base>();
            uiBase.Init();
        }

        _joystick.Init();
        _rjoystick.Init();
        _rjoystick.gameObject.SetActive(true);
        _joystick.gameObject.SetActive(false);

        _raycaster = GetComponent <GraphicRaycaster>();

        _Char = player.GetComponent <Char2D>();
    }
コード例 #4
0
 public void OnTriggerEnter2D(Collider2D collision)
 {
     if (collision.gameObject.name == "player")
     {
         Char2D myChar2D = FindObjectOfType <Char2D>();
         myChar2D.OnDamage(_attack);
         //피격 이펙트
     }
 }
コード例 #5
0
ファイル: AI_state.cs プロジェクト: platypus9511/source_code
    public virtual void Init(Enemy owner)
    {
        _owner = owner;
        _con   = _owner.GetComponent <Sentry_controller>();
        _anim  = owner.GetComponent <Animator>(); //owner의 Animator를 가져옴
        GameObject playerObj = GameManager.Instance._player;

        _player = playerObj.GetComponent <Char2D>();

        Debug.Log("스테이트 초기화 :" + GetType().ToString());
    }
コード例 #6
0
ファイル: DeadZone.cs プロジェクト: platypus9511/source_code
    private void OnTriggerEnter2D(Collider2D collision)
    {
        if (collision.gameObject.name == "player")
        {
            Char2D character = collision.gameObject.GetComponent <Char2D>();
            character.Ondie();

            Rigidbody2D rigid = collision.gameObject.GetComponent <Rigidbody2D>();
            rigid.bodyType = RigidbodyType2D.Static;
        }
    }
コード例 #7
0
ファイル: Enemy.cs プロジェクト: platypus9511/source_code
 public void OnCollisionEnter2D(Collision2D collision)
 {
     if (collision.gameObject.name == "playe")
     {
         Char2D playerChar = FindObjectOfType <Char2D>();
         playerChar.OnDamage(_data._attack);
         GameObject effectGo = Instantiate(_effectPrefab);
         Vector3    charPos  = playerChar.transform.position;
         effectGo.transform.position = new Vector3(charPos.x, charPos.y, charPos.z);
     }
 }
コード例 #8
0
ファイル: laser.cs プロジェクト: platypus9511/source_code
 private void OnTriggerEnter2D(Collider2D collision)
 {
     if (collision.gameObject.name == "player")
     {
         if (collision is CircleCollider2D)
         {
             return;
         }
         {
             Char2D player = collision.gameObject.GetComponent <Char2D>();
             player.OnDamage(1);
         }
     }
 }
コード例 #9
0
    public void ResPawn()
    {
        GameObject spawnPoint = _startPointList[_curStage - 1];
        Vector3    newpos     = spawnPoint.transform.position;
        Vector3    charpos    = _player.transform.position;

        _player.transform.position = new Vector3(newpos.x, newpos.y, charpos.z);


        Char2D playerCher = _player.GetComponent <Char2D>();

        playerCher.InitHP();

        // playerChar.

        uiManager.Instance.Show("Ui_play", true);

        Rigidbody2D rigid = _player.GetComponent <Rigidbody2D>();

        rigid.bodyType = RigidbodyType2D.Dynamic;
    }
コード例 #10
0
 public void Init(GameObject player)
 {
     _player = player.GetComponent <Char2D>();
     _con    = player.GetComponent <control>();
 }
コード例 #11
0
 // Start is called before the first frame update
 void Start()
 {
     character        = GetComponent <Char2D>();
     startPos         = transform.position;
     currentDirection = startDirection;
 }