///<summary>
    /// Updates the tool tip to display the correct amount of information on screen.
    ///</summary>
    void UpdateToolTip()
    {
        CreateBuilding cb = buildHolo.gameObject.GetComponent <CreateBuilding>();

        switch (iconTracker)
        {
        case 0:
            build_name.text = "Army Men Bucket";
            break;

        case 1:
            build_name.text = "Teddy Bear Chest";
            break;

        case 2:
            build_name.text = "Guard Turret";
            break;

        case 3:
            build_name.text = "Repair Station";
            break;

        default:
            break;
        }

        plastic_cost.text = cb.plasticCost.ToString() + " Plastic";
        fluff_cost.text   = cb.fluffCost.ToString() + " Fluff";
    }
Beispiel #2
0
    /// <summary>
    /// This function is called when any <see cref="Collider"/> enters this
    /// GameObject's trigger.
    /// <para>If that Collider is attached to a Tank the resource is added and
    /// this GameObject is destroyed.</para>
    /// </summary>
    /// <param name="other">Other.</param>
    override protected void OnTriggerEnter(Collider other)
    {
        if (IsPlayer(other))
        {
            // The collider is on the body of the tank, so search the parent for
            // the TankController
            TankController tc = other.GetComponentInParent <TankController>();
            // If the TankController wasn't found, then we hit a turret component,
            // so search the Turret's parent.
            if (tc == null)
            {
                tc = other.transform.parent.GetComponentInParent <TankController>();
            }

            if (tc.State == TankStates.Alive /* && tc.CanGrabResource(resourceType) */)
            {
                AddResource(tc);
                BuildMenuController bmc       = tc.bmc;
                GameObject          buildHolo = bmc.buildHolo;
                CreateBuilding      cb        = buildHolo.GetComponent <CreateBuilding>();
                base.OnTriggerEnter(other);
                cb.OnTriggerExit(other);
            }
        }

        if (IsWall(other) || IsBase(other) || (IsResource(other) /* && IsResource(this.GetComponent<Collider>()) */))
        {
            //Debug.Log("colliding with " + other + " with tag " + other.tag + "... destroying now");

            if (!boardControl.IsDoneWithPG)
            {
                base.OnTriggerEnter(other);
            }
        }
    }
    /// <summary>
    /// Calls the BuildBuilding function on the createBuilding script of the buildHolo object. This function
    /// is called from the TankController script.
    /// </summary>
    public void PlaceBuilding()
    {
        CreateBuilding cb = buildHolo.gameObject.GetComponent <CreateBuilding>();

        cb.BuildBuilding();
        //boardController.bakeNavMesh();
    }
Beispiel #4
0
 private void DoPlace(BaseEntity.RPCMessage msg)
 {
     if (!msg.player.CanInteract())
     {
         return;
     }
     using (CreateBuilding msg1 = CreateBuilding.Deserialize((Stream)msg.read))
         this.DoBuild(msg1);
 }
Beispiel #5
0
    void Start()
    {
        gameManagerObject = GameObject.FindWithTag("GameManager");
        gameManager       = gameManagerObject.GetComponent <GameManager>();
        createBuilding    = gameManagerObject.GetComponent <CreateBuilding>();

        Renderer renderer = this.GetComponent <Renderer>();

        GetComponent <Renderer>().material = groundMat;
    }
Beispiel #6
0
 private void DoPlace(BaseEntity.RPCMessage msg)
 {
     if (!msg.player.CanInteract())
     {
         return;
     }
     using (CreateBuilding createBuilding = CreateBuilding.Deserialize(msg.read))
     {
         this.DoBuild(createBuilding);
     }
 }
    public MinionObjectPooler(GameObject prefab, Transform parent, int max, GameObject bulletFondler)
        : base(prefab, parent, max)
    {
        if (!master_minion_fondler)
        {
            master_minion_fondler = CreateBuilding.FindMasterMinionFondler();
        }

        BulletFondler = bulletFondler;
        fondlerCount  = 0;
    }
    protected override void Awake()
    {
        base.Awake();

        name += " (" + (id++) + ")";

        if (findFondlerOnce)
        {
            master_minion_fondler = CreateBuilding.FindMasterMinionFondler();
            findFondlerOnce       = false;
        }

        minionsThisBatch = 0;

        minionPool = new MinionObjectPooler <MinionController>(minionToSpawn, minionFondler, maxMinions, bulletFondler);
        StartCoroutine(SpawnRoutine());
    }
Beispiel #9
0
    void BuildProccess()
    {
        //timer += Time.deltaTime;
        RaycastHit hit;

        Ray ray = cam.ScreenPointToRay(Input.mousePosition);

        Debug.DrawRay(ray.origin, ray.direction * 200, Color.yellow);

        if (Physics.Raycast(ray, out hit, 200.0f, 5))
        {
            //show build area
            buildArea.transform.position = hit.point;
            if (!buildArea.activeInHierarchy)
            {
                buildArea.SetActive(true);
            }



            if (Input.GetMouseButtonDown(0))
            {
                //if (timer >= PlaceRate)
                //{
                if (hit.collider.tag != "tower" && hit.collider.tag != "Enemy")
                {
                    buildArea.SetActive(false);
                    GameObject newBuilding = Instantiate(implamentedBuildings[selectedBuilding].structure, hit.point, new Quaternion(0, 0, 0, 0));
                    CommonAccessibles.ModeState = CommonAccessibles.Mode.COMMAND;
                    create = null;
                    // timer = 0;
                }

                //}
            }
        }
    }
Beispiel #10
0
    public void DoBuild(CreateBuilding msg)
    {
        BasePlayer ownerPlayer = base.GetOwnerPlayer();

        if (!ownerPlayer)
        {
            return;
        }
        if (ConVar.AntiHack.objectplacement && ownerPlayer.TriggeredAntiHack(1f, Single.PositiveInfinity))
        {
            ownerPlayer.ChatMessage("AntiHack!");
            return;
        }
        Construction construction = PrefabAttribute.server.Find <Construction>(msg.blockID);

        if (construction == null)
        {
            ownerPlayer.ChatMessage(string.Concat("Couldn't find Construction ", msg.blockID));
            return;
        }
        if (!this.CanAffordToPlace(construction))
        {
            ownerPlayer.ChatMessage("Can't afford to place!");
            return;
        }
        if (!ownerPlayer.CanBuild() && !construction.canBypassBuildingPermission)
        {
            ownerPlayer.ChatMessage("Building is blocked!");
            return;
        }
        Deployable deployable = this.GetDeployable();

        Construction.Target target     = new Construction.Target();
        BaseEntity          baseEntity = null;

        if (msg.entity > 0)
        {
            baseEntity = BaseNetworkable.serverEntities.Find(msg.entity) as BaseEntity;
            if (!baseEntity)
            {
                ownerPlayer.ChatMessage(string.Concat("Couldn't find entity ", msg.entity));
                return;
            }
            msg.position = baseEntity.transform.TransformPoint(msg.position);
            msg.normal   = baseEntity.transform.TransformDirection(msg.normal);
            msg.rotation = baseEntity.transform.rotation * msg.rotation;
            if (msg.socket == 0)
            {
                if (deployable && deployable.setSocketParent && baseEntity.Distance(msg.position) > 1f)
                {
                    ownerPlayer.ChatMessage(string.Concat("Parent too far away: ", baseEntity.Distance(msg.position)));
                    return;
                }
                if (baseEntity is Door)
                {
                    ownerPlayer.ChatMessage("Can't deploy on door");
                    return;
                }
            }
            target.entity = baseEntity;
            if (msg.socket > 0)
            {
                string str = StringPool.Get(msg.socket);
                if (!(str != "") || !(target.entity != null))
                {
                    ownerPlayer.ChatMessage("Invalid Socket!");
                }
                else
                {
                    target.socket = this.FindSocket(str, target.entity.prefabID);
                }
            }
        }
        target.ray       = msg.ray;
        target.onTerrain = msg.onterrain;
        target.position  = msg.position;
        target.normal    = msg.normal;
        target.rotation  = msg.rotation;
        target.player    = ownerPlayer;
        target.valid     = true;
        if (Interface.CallHook("CanBuild", this, construction, target) != null)
        {
            return;
        }
        if (deployable && deployable.placeEffect.isValid)
        {
            if (!baseEntity || msg.socket <= 0)
            {
                Effect.server.Run(deployable.placeEffect.resourcePath, msg.position, msg.normal, null, false);
            }
            else
            {
                Effect.server.Run(deployable.placeEffect.resourcePath, baseEntity.transform.TransformPoint(target.socket.worldPosition), baseEntity.transform.up, null, false);
            }
        }
        this.DoBuild(target, construction);
    }
Beispiel #11
0
    public void DoBuild(CreateBuilding msg)
    {
        BasePlayer ownerPlayer = this.GetOwnerPlayer();

        if (!Object.op_Implicit((Object)ownerPlayer))
        {
            return;
        }
        if (ConVar.AntiHack.objectplacement && ownerPlayer.TriggeredAntiHack(1f, float.PositiveInfinity))
        {
            ownerPlayer.ChatMessage("AntiHack!");
        }
        else
        {
            Construction component = PrefabAttribute.server.Find <Construction>((uint)msg.blockID);
            if ((PrefabAttribute)component == (PrefabAttribute)null)
            {
                ownerPlayer.ChatMessage("Couldn't find Construction " + (object)(uint)msg.blockID);
            }
            else if (!this.CanAffordToPlace(component))
            {
                ownerPlayer.ChatMessage("Can't afford to place!");
            }
            else if (!ownerPlayer.CanBuild() && !component.canBypassBuildingPermission)
            {
                ownerPlayer.ChatMessage("Building is blocked!");
            }
            else
            {
                Deployable          deployable = this.GetDeployable();
                Construction.Target target     = new Construction.Target();
                BaseEntity          baseEntity = (BaseEntity)null;
                if (msg.entity > 0)
                {
                    baseEntity = BaseNetworkable.serverEntities.Find((uint)msg.entity) as BaseEntity;
                    if (Object.op_Implicit((Object)baseEntity))
                    {
                        msg.position = (__Null)((Component)baseEntity).get_transform().TransformPoint((Vector3)msg.position);
                        msg.normal   = (__Null)((Component)baseEntity).get_transform().TransformDirection((Vector3)msg.normal);
                        msg.rotation = (__Null)Quaternion.op_Multiply(((Component)baseEntity).get_transform().get_rotation(), (Vector3)msg.rotation);
                        if (msg.socket == null)
                        {
                            if ((bool)((PrefabAttribute)deployable) && deployable.setSocketParent && (double)baseEntity.Distance((Vector3)msg.position) > 1.0)
                            {
                                ownerPlayer.ChatMessage("Parent too far away: " + (object)baseEntity.Distance((Vector3)msg.position));
                                return;
                            }
                            if (baseEntity is Door)
                            {
                                ownerPlayer.ChatMessage("Can't deploy on door");
                                return;
                            }
                        }
                        target.entity = baseEntity;
                        if (msg.socket > 0)
                        {
                            string name = StringPool.Get((uint)msg.socket);
                            if (name != "" && Object.op_Inequality((Object)target.entity, (Object)null))
                            {
                                target.socket = this.FindSocket(name, target.entity.prefabID);
                            }
                            else
                            {
                                ownerPlayer.ChatMessage("Invalid Socket!");
                            }
                        }
                    }
                    else
                    {
                        ownerPlayer.ChatMessage("Couldn't find entity " + (object)(uint)msg.entity);
                        return;
                    }
                }
                target.ray       = (Ray)msg.ray;
                target.onTerrain = (bool)msg.onterrain;
                target.position  = (Vector3)msg.position;
                target.normal    = (Vector3)msg.normal;
                target.rotation  = (Vector3)msg.rotation;
                target.player    = ownerPlayer;
                target.valid     = true;
                if (Interface.CallHook("CanBuild", (object)this, (object)component, (object)target) != null)
                {
                    return;
                }
                if ((bool)((PrefabAttribute)deployable) && deployable.placeEffect.isValid)
                {
                    if (Object.op_Implicit((Object)baseEntity) && msg.socket > 0)
                    {
                        Effect.server.Run(deployable.placeEffect.resourcePath, ((Component)baseEntity).get_transform().TransformPoint(target.socket.worldPosition), ((Component)baseEntity).get_transform().get_up(), (Connection)null, false);
                    }
                    else
                    {
                        Effect.server.Run(deployable.placeEffect.resourcePath, (Vector3)msg.position, (Vector3)msg.normal, (Connection)null, false);
                    }
                }
                this.DoBuild(target, component);
            }
        }
    }
Beispiel #12
0
 public override void ModeManagerResponceHandler(string val)
 {
     selectedBuilding = implamentedBuildings[val].name;
     create          += BuildProccess;
 }
Beispiel #13
0
        public ActionResult <CreateBuilding> PostBuilding(CreateBuilding request)

        {
            return(_buildingService.CreateBuiilding(request));
        }
Beispiel #14
0
 public async Task <IActionResult> PutBuilding(int id, CreateBuilding building)
 {
     _buildingService.UpdateBuilding(id, building);
     return(NoContent());
 }