コード例 #1
0
 private void ClearWindow()
 {
     TankBodySelector       = null;
     TankMobilitySelector   = null;
     TankAttachmentSelector = new TankyParts[0];
     InitialPosition        = Vector2.zero;
 }
コード例 #2
0
    public void InitiateGenerateTank()
    {
        TankyBody     basePart     = collectedParts.collectedBody[bodyDropdown.value];
        TankyMobility mobilityPart = collectedParts.collectedMobility[mobilityDropdown.value];

        TankyParts[] attachParts = new TankyParts[NumberOfConnectors];


        for (int i = 0; i < NumberOfConnectors; i++)
        {
            partInDropdown = partsHolder[i].GetComponentInChildren <TMP_Dropdown>().value;
            //Debug.Log("Part in Dropdown:" + partInDropdown);

            if (partInDropdown == 0)
            {
                //Debug.Log("It was 0");
                attachParts[i] = null;
            }
            else
            {
                if (partInDropdown <= collectedParts.collectedWeapon.Length)
                {
                    //Debug.Log("WeaponLookup:" + (partInDropdown - 1));
                    attachParts[i] = collectedParts.collectedWeapon[partInDropdown - 1];
                }
                else
                {
                    //Debug.Log("MiscLookup:" + (partInDropdown -1 - collectedParts.collectedWeapon.Length));
                    attachParts[i] = collectedParts.collectedMisc[partInDropdown - 1 - collectedParts.collectedWeapon.Length];
                }
            }
        }
        numberOfTanks++;
        tankSpawn.CreateTank(Vector3.zero + new Vector3((-3 * numberOfTanks), 0, 0), basePart, mobilityPart, attachParts);
    }
コード例 #3
0
    public void CreateTank(Vector3 spawnPosition, TankyBody basePart, TankyMobility mobilityPart, TankyParts[] attachParts)
    {
        //basePart = thisCollection.collectedBody[UnityEngine.Random.Range(0, thisCollection.collectedBody.Length)];
        //mobilityPart = thisCollection.collectedMobility[UnityEngine.Random.Range(0, thisCollection.collectedMobility.Length)];

        newTank = new GameObject("SpawnedTank");
        newTank.transform.position = spawnPosition;
        ownNavMeshAgent            = newTank.AddComponent <NavMeshAgent>();
        ownNavMeshAgent.speed      = 0;
        newTank.AddComponent <AIAiming>();
        newTank.AddComponent <AIMoving>();
        newTankCoreFunctions = newTank.AddComponent <TankCoreFunctions>();

        GeneratePart(basePart, newTank.transform);
        newTankCoreFunctions.bodyPart        = newPart;
        newBasePart.transform.localPosition -= mobilityPart.ownConnectorDistanceOffset;

        //Offset Body
        GeneratePart(mobilityPart, newTank.transform);
        newTankCoreFunctions.mobilityPart = newPart;

        for (int i = 0; i < attachParts.Length; i++)
        {
            if (attachParts[i] != null)
            {
                GeneratePart(attachParts[i], newBasePart.transform, basePart.connectorDistanceOffset[i], basePart.connectorAngleOffset[i]);
            }
        }


        /*
         * for (int i = 0; i < basePart.connectorAngleOffset.Length; i++)
         * {
         *  weaponPart = thisCollection.collectedWeapon[UnityEngine.Random.Range(0, thisCollection.collectedWeapon.Length)];
         *  miscPart = thisCollection.collectedMisc[UnityEngine.Random.Range(0, thisCollection.collectedMisc.Length)];
         *  switch (UnityEngine.Random.Range(0, 3))
         *  {
         *      case 0:
         *          break;
         *      case 1:
         *          GeneratePart(weaponPart, newBasePart.transform, basePart.connectorDistanceOffset[i], basePart.connectorAngleOffset[i]);
         *          break;
         *      case 2:
         *          GeneratePart(miscPart, newBasePart.transform, basePart.connectorDistanceOffset[i], basePart.connectorAngleOffset[i]);
         *          break;
         *  }
         *
         * }
         */
    }
コード例 #4
0
 void GenerateBody(TankyBody partToSpawn)
 {
     newBasePart = newPart;
 }