Inheritance: Photon.MonoBehaviour
 // Use this for initialization
 public void Start()
 {
     body = transform.GetComponent<BodyScript> ();
     GetOres ();
     vault = VaultScript.vault;
     //GameObject.FindWithTag ("MainBase").GetComponent<VaultScript>();
 }
Example #2
0
 /// <summary>
 /// 设置枚举字段
 /// </summary>
 /// <param name="name"></param>
 /// <returns></returns>
 public NEnum EnumField(string name)
 {
     if (BodyScript.Length > 0)
     {
         BodyScript.AppendLine(",");
     }
     BodyScript.Append(name);
     return(Link);
 }
Example #3
0
 /// <summary>
 /// 设置枚举字段
 /// </summary>
 /// <param name="name"></param>
 /// <param name="value"></param>
 /// <returns></returns>
 public NEnum EnumField(string name, int value)
 {
     if (BodyScript.Length > 0)
     {
         BodyScript.AppendLine(",");
     }
     BodyScript.Append($"{name}={value}");
     return(Link);
 }
Example #4
0
    public void TagRobot(GameObject gRobot_)
    {
        bDisabled = false;
        bBody     = gRobot_.GetComponent <BodyScript>();
        gGun      = gRobot_.GetComponentInChildren <GunScript>();
        sSword    = gRobot_.GetComponentInChildren <SwordScript>();

        //this is super superfulous(f**k spelling lmao) and and probably be made into tags.
        bBody.sOwner  = tag;
        gGun.sOwner   = tag;
        sSword.sOwner = tag;
        //like so
        bBody.tag  = tag;
        gGun.tag   = tag;
        sSword.tag = tag;
    }
Example #5
0
    public void SignalToMove(Vector3 New)
    {
        Vector3 Old = transform.position;

        transform.position = New;
        if (NextNode != null)
        {
            NextNode.SignalToMove(Old);
        }
        else if (NextNode == null && ShouldReproduce)
        {
            ShouldReproduce = false;
            GameObject GO = Instantiate(BodyPrefab, Old, Quaternion.identity);
            NextNode = GO.GetComponent <BodyScript>();
        }
    }
Example #6
0
    private GameObject CreateBodyObject(ulong id)
    {
        GameObject body = new GameObject("Body:" + id);

        Rigidbody rb = body.AddComponent <Rigidbody>();

        rb.isKinematic = true;

        BodyScript bs = body.AddComponent <BodyScript>();

        bs.camera = mainCamera;

        GameObject jointObj = GameObject.CreatePrimitive(PrimitiveType.Cube);

        jointObj.transform.localScale = new Vector3(0.3f, 0.3f, 0.3f);
        jointObj.name             = Kinect.JointType.SpineBase.ToString();
        jointObj.transform.parent = body.transform;

        return(body);
    }
 // Use this for initialization
 public void Start()
 {
     body = transform.GetComponent<BodyScript> ();
     //var hammer = GameObject.Find ("1-2-0 Hammer");
     //if (hammer == null){
     //	hammer = (Resources.Load ("Prefabs/1-2-0 Hammer")) as GameObject;
     //}
     //attackProjectile = hammer;
 }
        /// <summary>
        /// click event that should trigger when clicking the 'load' button
        /// </summary>
        public void LoadSelectedBlueprint()
        {
            GameObject rootGameObject = null;

            try
            {
                if (BlueprintMenu.blueprintObject != null)
                {
                    //clean up existing blueprintobject
                    Destroy(BlueprintMenu.blueprintObject.gameObject);
                }

                Debug.Log("trying to load bp");

                BlueprintData blueprintData = SelectedBlueprintButton.BlueprintContextReference.LoadBlueprint();


                rootGameObject = Instantiate(GameController.Instance.Blueprint);
                BlueprintScript blueprintScript = rootGameObject.GetComponent <BlueprintScript>();

                int shapeIdx = 0;

                foreach (var body in blueprintData.Bodies)
                {
                    GameObject bodyGameObject = Instantiate(GameController.Instance.Body, rootGameObject.transform);
                    BodyScript bodyScript     = bodyGameObject.GetComponent <BodyScript>();

                    blueprintScript.Bodies.Add(bodyScript);
                    foreach (var child in body.Childs)
                    {
                        ChildScript childScript = CreateChildObject(child, bodyGameObject);
                        childScript.shapeIdx = shapeIdx;
                        childScript.Body     = bodyScript;

                        bodyScript.Childs.Add(childScript);
                        shapeIdx++;
                    }
                }
                if (blueprintData.Joints != null)
                {
                    foreach (var joint in blueprintData.Joints)
                    {
                        blueprintScript.Joints.Add(CreateJointObject(joint, rootGameObject));
                    }
                }

                ArrangeJointReferencesUsingData(blueprintScript, blueprintData);

                #region handle camera position
                PlayerController playerController = GameController.Instance.playerController;
                if (playerController.snapToCreation)
                {
                    Camera camera      = playerController.gameObject.GetComponent <Camera>();
                    var    center      = blueprintScript.CalculateCenter();
                    var    destination = center - camera.transform.forward * playerController.distanceToSnap;

                    var cameraState = playerController.m_TargetCameraState;

                    cameraState.x = destination.x;
                    cameraState.y = destination.y;
                    cameraState.z = destination.z;
                    //GameObject.Find("Sphere").transform.position = center;
                }
                #endregion

                BlueprintMenu.blueprintObject = blueprintScript;
                Debug.Log("successfully loaded bp");
            }
            catch (Exception e)
            {
                Debug.LogException(new Exception($"\nan error occurred while loading this blueprint.", e));
                if (rootGameObject != null)
                {
                    Debug.Log("failed loading blueprint");
                    Destroy(rootGameObject);
                }
            }
        }