void OnTriggerEnter(Collider triggeredCollider)
    {
        if (triggeredCollider.gameObject.tag == "velcroTag")
        {
            GameObject     theirParent    = triggeredCollider.transform.parent.gameObject;
            ComponentClass theirComponent = theirParent.GetComponent <ComponentClass>();

            if (debug)
            {
                Debug.Log("Trying to connect to: " + theirParent.name);
            }

            //if we can connect, try to!
            if (canToggleTrigger)
            {
                ConnectTo(theirParent, theirComponent, triggeredCollider.gameObject);
            }
            else
            {
                if (debug)
                {
                    Debug.Log("Unable to connect to velcro.");
                }
            }
        }
    }
예제 #2
0
 void Start()
 {
     rotateAxis   = gameObject.transform.forward;
     forceFactor  = 5;
     torqueFactor = 5;
     wheelFactor  = 20;
     myComponent  = gameObject.GetComponent <ComponentClass>();
 }
    void Start()
    {
        //set some states
        canToggleTrigger = true;

        //assign stuff
        myObject    = gameObject.transform.parent.gameObject;
        myComponent = myObject.GetComponent <ComponentClass>();
    }
예제 #4
0
        private void UpdateComponentMin(string componentName, double minAmount)
        {
            componentName = CorrectComponent(componentName);

            if (!componentList.ContainsKey(componentName))
            {
                componentList[componentName]             = new ComponentClass();
                componentList[componentName].itemSubType = componentName;
            }
            componentList[componentName].minCount = minAmount;
        }
예제 #5
0
        private void AddComponentCount(MyInventoryItem item)
        {
            string itemType      = item.Type.TypeId.Substring(16);
            string componentName = $"{item.Type.SubtypeId}";

            componentName = CorrectComponent(componentName);

            if (!componentList.ContainsKey(componentName))
            {
                componentList[componentName]             = new ComponentClass();
                componentList[componentName].itemSubType = componentName;
            }
            componentList[componentName].itemCount += (double)item.Amount;
        }
예제 #6
0
        private void AddComponentBuild(MyProductionItem item)
        {
            //Echo($"{item.ItemId}|{item.BlueprintId}|{item.Amount}\n");
            string componentName = item.BlueprintId.SubtypeName;

            //Echo(componentName);


            componentName = CorrectComponent(componentName);

            if (!componentList.ContainsKey(componentName))
            {
                componentList[componentName]             = new ComponentClass();
                componentList[componentName].itemSubType = componentName;
            }
            componentList[componentName].buildCount += (double)item.Amount;
        }
예제 #7
0
    static void SaveObject(GameObject go, GameObjectClass parent)
    {
        Component[] comps = go.GetComponents <Component>();
        foreach (var comp in comps)
        {
            ComponentClass childComp = ComponentFactory.CreateComponentClass(comp);
            parent.components.Add(childComp);
        }
        for (var i = 0; i < go.transform.childCount; i++)
        {
            GameObject      child   = go.transform.GetChild(i).transform.gameObject;
            GameObjectClass childGO = new GameObjectClass(child);
            parent.children.Add(childGO);

            SaveObject(child, childGO);
        }
    }
 //for connecting two components together
 void ConnectTo(GameObject connectObject, ComponentClass connectComponent, GameObject theirVelcro)
 {
     //If I am the core of the robot
     if (myComponent.isCentrePart)
     {
         if (connectComponent.isCentrePart)
         {
             if (debug)
             {
                 Debug.LogError("Yeah, you can't connect two robot centres.");
             }
         }
         else
         {
             if (connectComponent.isAttachedToSomething)
             {
                 if (debug)
                 {
                     Debug.LogWarning("You're already attached!");
                 }
             }
             else
             {
                 VelcroThemToUs(connectObject, connectComponent, theirVelcro);
             }
         }
     }
     //If I am NOT the core of the robot
     else
     {
         if (myComponent.isAttachedToSomething && !connectComponent.isCentrePart)
         {
             VelcroThemToUs(connectObject, connectComponent, theirVelcro);
         }
         else
         {
             if (debug)
             {
                 Debug.LogWarning("You can't connect two extra parts together.");
             }
         }
     }
 }
    void VelcroThemToUs(GameObject connectObject, ComponentClass connectComponent, GameObject velcro)
    {
        if (connectObject.GetComponent <Rigidbody> () != null)
        {
            connectObject.GetComponent <Rigidbody>().useGravity  = false;
            connectObject.GetComponent <Rigidbody>().isKinematic = true;
        }
        else if (debug)
        {
            Debug.LogWarning(connectObject.name + " does not have a rigidbody!");
        }

        connectObject.transform.parent         = myObject.transform;
        connectComponent.isAttachedToSomething = true;

        //for each hand grabbing it, make them stop and forget about it.
        for (int i = 0; i < connectComponent.handsOnThis.Count; i++)
        {
            ViveControllers controller = connectComponent.handsOnThis[i];
            controller.grabbedObject = null;
        }
        //when done, clear the hands List
        connectComponent.handsOnThis = new List <ViveControllers>();

        //SnapToCORRECTPosition(connectObject, velcro);

        if (debug)
        {
            Debug.Log(myObject.name + " has connected " + connectObject.name + " to itself.");
        }

        //THIS COULD KILL EVERYTHING
        //BEWARE
        //ERRORS INBOUND:
        Destroy(connectObject.GetComponent <Rigidbody>());
        if (debug)
        {
            Debug.LogWarning("DESTROYED " + connectObject.name + "'s RIGIDBODY!");
        }
    }
예제 #10
0
    //FOR GRABBING THINGS
    private void CheckGrabThings()
    {
        if (triggerDown && grabSlot != null && grabbedObject == null)
        {
            //we're grabbing this object
            grabbedObject = getObjectToGrab(grabSlot);
            if (debug)
            {
                Debug.Log("Grabbed: " + grabbedObject.name);
            }

            //access its component
            component = grabbedObject.GetComponent <ComponentClass>();
            //add yourself to its list
            component.handsOnThis.Add(gameObject.GetComponent <ViveControllers>());

            //do all the grabbing stuff
            grabbedObject.transform.parent = gameObject.transform;

            if (grabbedObject.GetComponent <Rigidbody> () != null)
            {
                grabbedObject.GetComponent <Rigidbody>().useGravity  = false;
                grabbedObject.GetComponent <Rigidbody>().isKinematic = true;
            }
            else
            {
                if (debug)
                {
                    Debug.LogWarning(grabbedObject.name + " does not have a rigidbody!");
                    Debug.LogWarning("Giving " + grabbedObject.name + " a rigidbody!");
                }
                grabbedObject.AddComponent <Rigidbody>();
                grabbedObject.GetComponent <Rigidbody>().useGravity  = false;
                grabbedObject.GetComponent <Rigidbody>().isKinematic = true;
            }

            component.ReplaceMe();
        }
    }
예제 #11
0
 public void TargetRpcCantHaveParamComponent(NetworkConnection monkeyCon, ComponentClass monkeyComp)
 {
 }
 public void RpcCantHaveParamComponent(ComponentClass monkeyComp)
 {
 }
예제 #13
0
        protected override void InitializeComponentPools()
        {
            MaxGameObjects  = 10000;
            mGameObjectPool = new GameObjectPool(MaxGameObjects);

            int renderedObjects = MaxGameObjects;//what game objects are inportant but not rendered?

            int particals    = 1000;
            int collectables = 1500;
            int projectiles  = 200;
            //int simplePhysicsEntities = 15;
            int players = 1;
            int enemies = 1500;

            //int wanderEnemies = 1500;
            //int patrolEnemies = 200;
            //int circularEnemies = 200;
            //int ninjas = 200;

            //int staticSets = 15;

            ComponentClass[] componentTypes =
            {
                //new ComponentClass(AnimationComponent.class, 384),
                //new ComponentClass(AttackAtDistanceComponent.class, 16),
                //new ComponentClass(enemies+players+particals+projectiles, typeof(BackgroundCollisionComponent)),
                //new ComponentClass(ButtonAnimationComponent.class, 32),
                //new ComponentClass(CameraBiasComponent.class, 8),
                //new ComponentClass(circularEnemies, typeof(CircularAIComponent)),
                //new ComponentClass(ChangeComponentsComponent.class, 256),
                //new ComponentClass(DoorAnimationComponent.class, 256),  //!
                //new ComponentClass(enemies+players+projectiles, typeof(DynamicCollisionComponent)),
                //new ComponentClass(EnemyAnimationComponent.class, 256),
                //new ComponentClass(FadeDrawableComponent.class, 32),
                //new ComponentClass(FixedAnimationComponent.class, 8),
                //new ComponentClass(FrameRateWatcherComponent.class, 1),
                //new ComponentClass(GenericAnimationComponent.class, 32),
                //new ComponentClass(staticSets, typeof(GravityComponent)),
                //new ComponentClass(collectables+enemies, typeof(HitPlayerComponent)),
                //new ComponentClass(collectables+enemies+players, typeof(HitReactionComponent)),
                //new ComponentClass(players, typeof(InventoryComponent)),
                //new ComponentClass(players+ninjas, typeof(LaunchProjectileComponent)),
                new ComponentClass(enemies + players + particals + collectables + projectiles, typeof(LifetimeComponent)),
                //new ComponentClass(staticSets, typeof(MovementComponent)),
                //new ComponentClass(NPCAnimationComponent.class, 8),
                //new ComponentClass(NPCComponent.class, 8),
                //new ComponentClass(OrbitalMagnetComponent.class, 1),
                //new ComponentClass(patrolEnemies,typeof(PatrolAIComponent)),
                //new ComponentClass(staticSets, typeof(PhysicsComponent)),
                //new ComponentClass(players, typeof(PlayerComponent)),
                //new ComponentClass(wanderEnemies,typeof(PursuitAIComponent)),
                new ComponentClass(renderedObjects,                                            typeof(RenderComponent)),
                //new ComponentClass(SimpleCollisionComponent.class, 32),
                //new ComponentClass(simplePhysicsEntities, typeof(SimplePhysicsComponent)),
                //new ComponentClass(enemies, typeof(SolidSurfaceComponent)),
                new ComponentClass(collectables + enemies + players,                           typeof(SpriteComponent)),
                //new ComponentClass(wanderEnemies,typeof(WanderAIComponent)),
            };

            mComponentPools = new FixedSizeArray <FreshGameComponentPool>(componentTypes.Length, sComponentPoolComparator);
            for (int x = 0; x < componentTypes.Length; x++)
            {
                ComponentClass component = componentTypes[x];
                mComponentPools.Add(new FreshGameComponentPool(component.type, component.poolSize));
            }
            mComponentPools.Sort(true);

            mPoolSearchDummy = new FreshGameComponentPool(typeof(object), 1);
        }
예제 #14
0
 void Start()
 {
     forceFactor = 10;
     spinFactor  = 10;
     myComponent = gameObject.GetComponent <ComponentClass>();
 }