Exemple #1
0
        public Projectile Create(ActorBody player, Vector3 position, Quaternion rotation)
        {
            var p = Instantiate(this, position, rotation);

            p.owner = player;
            return(p);
        }
        /**
         * Initialized
         */
        public void Awake()
        {
            rb	= GetComponent<Rigidbody> ();
            ab	= GetComponent<ActorBody> ();

            // If we're not being used on an Actor
            if (!ab)
            {
                if (!rb)
                    rb = gameObject.AddComponent<Rigidbody> ();
                rb.isKinematic = true;
                rb.useGravity = false;
                rb.interpolation = RigidbodyInterpolation.Interpolate;
            }

            foreach (Transform child in transform)
                if (child.tag == "Waypoint")
                    waypoints.Add (child);

            foreach (Transform wp in waypoints)
                wp.parent = null;

            if (waypoints.Count == 0) {
                Debug.Log("No waypoints tagged for PatrolWaypoints script");
            }
        }
Exemple #3
0
        /**
         * Initialized
         */
        public void Awake()
        {
            rb = GetComponent <Rigidbody> ();
            ab = GetComponent <ActorBody> ();

            // If we're not being used on an Actor
            if (!ab)
            {
                if (!rb)
                {
                    rb = gameObject.AddComponent <Rigidbody> ();
                }
                rb.isKinematic   = true;
                rb.useGravity    = false;
                rb.interpolation = RigidbodyInterpolation.Interpolate;
            }

            foreach (Transform child in transform)
            {
                if (child.tag == "Waypoint")
                {
                    waypoints.Add(child);
                }
            }

            foreach (Transform wp in waypoints)
            {
                wp.parent = null;
            }

            if (waypoints.Count == 0)
            {
                Debug.Log("No waypoints tagged for PatrolWaypoints script");
            }
        }
Exemple #4
0
 public virtual void Awake()
 {
     motor = this.GetComponent <Motor>();
     body  = this.GetComponentInChildren <ActorBody>();
     if (body != null)
     {
         body.actor = this;
     }
 }
        /**
         * Initialize
         */
        void Awake()
        {
            if (tag != "Player")
            {
                tag = "Player";
                Debug.LogWarning("PlayerController script assigned to object without the tag 'Player', tag has been assigned to object", transform);
            }

            // Bump up jumpforce
            jumpForce *= 100;

            // Assign references
            anim = GetComponent <Animator> ();
            ab   = GetComponent <ActorBody> ();
            rb   = GetComponent <Rigidbody> ();
            cldr = GetComponent <Collider> ();
            cam  = GameObject.FindGameObjectWithTag("MainCamera").transform;
        }
Exemple #6
0
        /**
         * Initialization
         */
        void Awake()
        {
            if (!grabBox)
            {
                grabBox      = new GameObject();
                grabBox.name = "GrabSensor";
                Collider collider = grabBox.AddComponent <SphereCollider> ();
                collider.isTrigger              = true;
                grabBox.transform.parent        = transform;
                grabBox.transform.localPosition = new Vector3(0f, 0f, 1.5f);
                grabBox.layer = 2;                                                           // Ignore raycasts
                Debug.Log("Created 'grabBox' for grab sensing");
            }

            playerController = GetComponent <PlayerController> ();
            actorBody        = GetComponent <ActorBody> ();
            rigidBody        = GetComponent <Rigidbody> ();
            defRotateSpeed   = playerController.rotateSpeed;
        }
Exemple #7
0
    void Awake()
    {
        machine = new BasicMachine <PartState>();
        machine.Initialize(typeof(PartState));
        machine.OnChange = OnChange;
        machine[(int)PartState.ATTACHED].OnEnter   = OnAttach;
        machine[(int)PartState.ATTACHED].CanEnter  = CanSwitch;
        machine[(int)PartState.ALIGNING].OnEnter   = OnAlign;
        machine[(int)PartState.ALIGNING].CanEnter  = CanSwitch;
        machine[(int)PartState.ANIMATING].OnEnter  = OnAnimate;
        machine[(int)PartState.ANIMATING].CanEnter = CanSwitch;
        machine[(int)PartState.HELD].OnEnter       = OnHeld;
        machine[(int)PartState.HELD].CanEnter      = CanSwitch;
        machine[(int)PartState.GLUED].OnEnter      = OnGlued;
        machine[(int)PartState.GLUED].CanEnter     = CanSwitch;
        machine[(int)PartState.LAUNCH].OnEnter     = OnLaunch;
        machine[(int)PartState.LAUNCH].CanEnter    = CanSwitch;
        machine[(int)PartState.DORMANT].OnEnter    = OnDormant;
        machine[(int)PartState.DORMANT].CanEnter   = CanSwitch;
        machine[(int)PartState.GROWING].OnEnter    = OnGrow;
        machine[(int)PartState.GROWING].CanEnter   = CanSwitch;

        thisTransform = this.transform;
        thisRenderer  = this.GetComponent <Renderer>();
        thisBody      = this.GetComponentInParent <ActorBody>();
        bodyParent    = thisTransform.parent;
        handParent    = null;
        limbParent    = parentPart != null ? parentPart.transform : null;
        originalPos   = thisTransform.localPosition;
        originalRot   = thisTransform.localRotation;
        originalScale = thisTransform.localScale;
        if (thisBody != null)
        {
            machine.SetState(PartState.ATTACHED);
        }
        CheckDepth();
    }
Exemple #8
0
        /**
         * Initialization
         */
        void Awake()
        {
            if (!grabBox)
            {
                grabBox								= new GameObject ();
                grabBox.name						= "GrabSensor";
                Collider collider					= grabBox.AddComponent<SphereCollider> ();
                collider.isTrigger					= true;
                grabBox.transform.parent			= transform;
                grabBox.transform.localPosition		= new Vector3 (0f, 0f, 1.5f);
                grabBox.layer						= 2; // Ignore raycasts
                Debug.Log ("Created 'grabBox' for grab sensing");
            }

            playerController	= GetComponent<PlayerController> ();
            actorBody			= GetComponent<ActorBody> ();
            rigidBody			= GetComponent<Rigidbody> ();
            defRotateSpeed		= playerController.rotateSpeed;
        }
Exemple #9
0
 void Awake()
 {
     actor     = gameObject.GetComponent <Actor>();
     this.body = actor.body;
 }
        /**
         * Initialize
         */
        void Awake()
        {
            if (tag != "Player")
            {
                tag = "Player";
                Debug.LogWarning ("PlayerController script assigned to object without the tag 'Player', tag has been assigned to object", transform);
            }

            // Bump up jumpforce
            jumpForce *= 100;

            // Assign references
            anim	= GetComponent<Animator> ();
            ab		= GetComponent<ActorBody> ();
            rb		= GetComponent<Rigidbody> ();
            cldr	= GetComponent<Collider> ();
            cam		= GameObject.FindGameObjectWithTag ("MainCamera").transform;
        }