protected virtual void Initialization()
    {
        State            = new DHPhysicsControllerState();
        behaviourManager = GetComponent <BasicBehaviour>();
        input            = behaviourManager.LinkedInputManager;
        _rigidbody       = behaviourManager.GetRigidBody;
        animator         = behaviourManager.GetAnimator;
        mainCamara       = behaviourManager.Getcamera;
        _rigidbody       = behaviourManager.GetRigidBody;

        frictionPhysics                 = new PhysicMaterial();
        frictionPhysics.name            = "frictionPhysics";
        frictionPhysics.staticFriction  = .25f;
        frictionPhysics.dynamicFriction = .25f;
        frictionPhysics.frictionCombine = PhysicMaterialCombine.Multiply;

        maxFrictionPhysics                 = new PhysicMaterial();
        maxFrictionPhysics.name            = "maxFrictionPhysics";
        maxFrictionPhysics.staticFriction  = 1f;
        maxFrictionPhysics.dynamicFriction = 1f;
        maxFrictionPhysics.frictionCombine = PhysicMaterialCombine.Maximum;

        slippyPhysics                 = new PhysicMaterial();
        slippyPhysics.name            = "slippyPhysics";
        slippyPhysics.staticFriction  = 0f;
        slippyPhysics.dynamicFriction = 0f;
        slippyPhysics.frictionCombine = PhysicMaterialCombine.Minimum;

        _capsuleCollider = GetComponent <CapsuleCollider>();

        colliderCenter = GetComponent <CapsuleCollider>().center;
        colliderRadius = GetComponent <CapsuleCollider>().radius;
        colliderHeight = GetComponent <CapsuleCollider>().height;
    }
    protected int behaviourCode;                       // The code that identifies a behaviour.

    void Awake()
    {
        // Set up the references.
        behaviourManager = GetComponent <BasicBehaviour> ();
        speedFloat       = Animator.StringToHash("Speed");

        // Set the behaviour code based on the inheriting class.
        behaviourCode = this.GetType().GetHashCode();
    }
Exemple #3
0
    // 削除
    public virtual void Remove(BasicBehaviour basicBehaviour)
    {
        // 登録確認
        if (!_behaviourList.Contains(basicBehaviour))
        {
            return;
        }

        // 削除
        _behaviourList.Remove(basicBehaviour);
    }
    protected float distToGround;                      // Actual distance to ground.

    void Awake()
    {
        // Set up the references.
        anim             = GetComponent <Animator> ();
        rbody            = GetComponent <Rigidbody> ();
        behaviourManager = GetComponent <BasicBehaviour> ();
        camScript        = behaviourManager.playerCamera.GetComponent <ThirdPersonOrbitCam> ();
        speedFloat       = Animator.StringToHash("Speed");
        canSprint        = true;

        // Set the behaviour code based on the inheriting class.
        behaviourCode = this.GetType().GetHashCode();
        distToGround  = GetComponent <Collider>().bounds.extents.y;
    }
Exemple #5
0
    protected virtual void OnTriggerEnter(Collider other)
    {
        // hit walls
        if (!other.isTrigger && other.tag != "Player")
        {
            if (verbose)
            {
                Debug.Log("hit walls");
            }
            Destroy(gameObject);
            return;
        }

        var destructable = other.transform.GetComponent <Destructable>();

        if (destructable == null)
        {
            destructable = other.transform.GetComponentInParent <Destructable>();
        }
        if (destructable == null)
        {
            if (verbose)
            {
                Debug.Log(other.name + " is not destructable");
            }
            return;
        }

        if (other.tag == "Player")
        {
            BasicBehaviour player = GameManager.Instance.LocalPlayer;
            PlayerSkill    pk     = player.GetComponent <PlayerSkill>();
            if (pk.skill1working)
            {
                if (verbose)
                {
                    Debug.Log("Player are intangible now!");
                }
                return;
            }
        }

        destructable.TakeDamege(damage);
        Destroy(gameObject);
    }
Exemple #6
0
    protected virtual void Initialization()
    {
        behaviourManager = GetComponent <BasicBehaviour>();
        _controller      = GetComponent <DHPhysicsController>();

        movement             = behaviourManager.movementState;
        condition            = behaviourManager.conditionState;
        speedFloat           = Animator.StringToHash("Speed");
        _animator            = behaviourManager.GetAnimator;
        inputmanager         = behaviourManager.LinkedInputManager;
        _rigidbody           = behaviourManager.GetRigidBody;
        behaviourInitialized = true;

        if (_animator != null)
        {
            InitializeAnimatorParameters();
        }
    }
Exemple #7
0
    protected virtual IEnumerator SetUpSocket()
    {
        while (BasicBehaviour.instance == null)
        {
            Debug.Log("Waiting for instance");
            yield return(new WaitForSeconds(0.5f));
        }

        behaviour = BasicBehaviour.instance;
        behaviour.GetWS().OnOpen += () =>
        {
            readyForId = true;
        };
        behaviour.GetWS().OnMessage += (byte[] msg) =>
        {
            ProcessMessage(Encoding.UTF8.GetString(msg));
        };
    }
Exemple #8
0
    // Use this for initialization
    protected void Start()
    {
        // Singelton
        if (instance != null)
        {
            Destroy(this);
        }

        if (instance == null)
        {
            instance = this;
        }

        if (Application.platform != RuntimePlatform.WebGLPlayer)
        {
            adress = "ws://joye.dev:9001/";
        }
        adress = adress + target;

        // Create WebSocket instance
        Debug.Log("Connecting to " + adress);
        ws = WebSocketFactory.CreateInstance(adress);

        // Add OnError event listener
        ws.OnError += (string errMsg) =>
        {
            Debug.Log("Chat error: " + errMsg);
        };

        // Add OnClose event listener
        ws.OnClose += (WebSocketCloseCode code) =>
        {
            Debug.Log("Chat closed with code: " + code.ToString());
        };

        // Connect to the server
        ws.Connect();

        StartCoroutine(Ping());
    }
    protected virtual void OnTriggerEnter(Collider other)
    {
        // hit walls
        if (!other.isTrigger && other.tag != "Player")
        {
            Debug.Log("hit walls");
            Destroy(gameObject);
            return;
        }

        var destructable = other.transform.GetComponent <Destructable>();

        if (destructable == null)
        {
            destructable = other.transform.GetComponentInParent <Destructable>();
        }
        if (destructable == null)
        {
            Debug.Log(other.name + " is not destructable");
            return;
        }

        if (other.tag == "Player")
        {
            BasicBehaviour player = GameManager.Instance.LocalPlayer;
            PlayerHealth   ph     = player.GetComponent <PlayerHealth>();
            if (ph.Intangible)
            {
                Debug.Log("hide " + ph.Intangible);
                return;
            }
        }

        destructable.TakeDamege(damage);
        Destroy(gameObject);
    }
Exemple #10
0
 // Use this for initialization
 void Start()
 {
     basic = GetComponent <BasicBehaviour>();
     move  = GetComponent <MoveBehaviour>();
 }
Exemple #11
0
 // 登録
 public virtual void Entry(BasicBehaviour basicBehaviour)
 {
     _behaviourList.Add(basicBehaviour);
 }
Exemple #12
0
 void Awake()
 {
     bb = GetComponent <BasicBehaviour>();
     mb = GetComponent <MoveBehaviour>();
     rb = GetComponent <Rigidbody>();
 }