コード例 #1
0
    void Start()
    {
        canMove           = true;
        playerInput       = gameObject.GetComponent <GlobalInput>();
        characterBody     = gameObject.GetComponent <Rigidbody>();
        characterCollider = gameObject.GetComponent <CapsuleCollider>();

        characterBody.freezeRotation = true;
    }
コード例 #2
0
        private void Update()
        {
            if (presenter == null)
            {
                return;
            }

            if (Input.GetKeyDown(toogleKey))
            {
                if (presenter.IsActive)
                {
                    GlobalInput.SetCharacterMode();
                    presenter.Deactivate();
                }
                else
                {
                    GlobalInput.SetInterfaceMode();
                    presenter.Activate();
                }
            }
        }
コード例 #3
0
ファイル: GameController.cs プロジェクト: LuckyBYR/RPG
    void Start()
    {
        GlobalItens.Init();
        GlobalCharacter.Init();
        GlobalWorldMap.Init();
        GlobalQuests.Init();
        GlobalMap.Init();
        GlobalInput.Init();

        _itens = new ArrayList();
        _npcs  = new ArrayList();

        AddItemToMap(GlobalItens.generateAlchemy(AlchemyType.HealLife), new Vector3(64, 96, -5));


        GameCharacter test = GlobalCharacter.generetaChar();

        test.name   = "ERRROR";
        test.sprite = 5;

        AddCharacterToMap(test, new Vector3(32, 32, -10));
    }
コード例 #4
0
ファイル: GUIManager.cs プロジェクト: gormed/darwin
 // Use this for initialization
 void Start()
 {
     UnityEngine.Object.DontDestroyOnLoad(this);
     GlobalInput.RegisterListener(InputManager.InputCategory.GUI, this);
 }
コード例 #5
0
    void FixedUpdate()
    {
        if (Input.GetMouseButtonDown(0) && GlobalInput.verifyInput(InputType.GameMap))
        {
            RaycastHit hit;
            Ray        ray = Camera.main.ScreenPointToRay(Input.mousePosition);

            if (Physics.Raycast(ray, out hit))
            {
                moveTo(hit.transform.position.x, hit.transform.position.y);
                if (hit.collider.gameObject.GetComponent <ItemBase>() != null)
                {
                    //Debug.Log("ITEM");
                    _targetType = ObjectType.Item;
                    _target     = hit.collider.gameObject;
                }
                else if (hit.collider.gameObject.GetComponent <TileChanges>() != null)
                {
                    //Debug.Log("TILE");
                    if (hit.collider.gameObject.GetComponent <ActionTile>() != null)
                    {
                        _targetType = ObjectType.Tile;
                        _target     = hit.collider.gameObject;
                    }
                }
                else if (hit.collider.gameObject.GetComponent <GameCharacterController>() != null)
                {
                    //Debug.Log("CHARACTER");
                    _targetType = ObjectType.Character;
                    _target     = hit.collider.gameObject;
                }
            }
        }

        if (Mathf.Abs(_targetPos.x - this.transform.position.x) < 1)
        {
            this.rigidbody.velocity = new Vector3(0, this.rigidbody.velocity.y, 0);
        }
        else
        {
            if (_targetPos.x - this.transform.position.x < 0)
            {
                this.rigidbody.velocity = new Vector3(-charSpeed, this.rigidbody.velocity.y, 0);
                scriptAnim.moveLeft();
            }
            else
            {
                this.rigidbody.velocity = new Vector3(charSpeed, this.rigidbody.velocity.y, 0);
                scriptAnim.moveRight();
            }
        }
        if (Mathf.Abs(_targetPos.y - this.transform.position.y) < 1)
        {
            this.rigidbody.velocity = new Vector3(this.rigidbody.velocity.x, 0, 0);
        }
        else
        {
            if (_targetPos.y - this.transform.position.y < 0)
            {
                this.rigidbody.velocity = new Vector3(this.rigidbody.velocity.x, -charSpeed, 0);
                scriptAnim.moveDown();
            }
            else
            {
                this.rigidbody.velocity = new Vector3(this.rigidbody.velocity.x, charSpeed, 0);
                scriptAnim.moveUp();
            }
        }

        if (this.rigidbody.velocity.x == 0 && this.rigidbody.velocity.y == 0)
        {
            scriptAnim.hasAnim = false;
        }
    }