// Start is called before the first frame update
 void Start()
 {
     //get the botcontroller located in HealthAndCDHoolder script
     botController = transform.parent.GetComponentInParent <HealthAndCDHolder>().GetBotController();
     //get the botpart
     botPart = botController.slots.GetSlotBotPart(slotPosition);
     //check if bot part does not exists in slot
     if (!botPart)
     {
         //get all children transforms for this cooldown bar
         var childrenTransforms = GetComponentsInChildren <Transform>();
         //Loop through each transform
         foreach (var _transform in childrenTransforms)
         {
             //if botpart doesn't exist in slot gameobject will be deactivated
             _transform.gameObject.SetActive(false);
         }
     }
 }
Example #2
0
 void OnTriggerStay(Collider c)
 {
     if (c.gameObject.CompareTag("Bot") && botMode == BotMode.Follow)
     {
         BotPart botPart = c.GetComponent <BotPart>();
         if (botPart != null)
         {
             GameObject bot = botPart.GetParentBot();
             if (bot != null)
             {
                 BotMovement botScript = bot.GetComponent <BotMovement>();
                 if (botScript != null)
                 {
                     BumpBot(botScript);
                 }
             }
         }
     }
 }
Example #3
0
 void OnTriggerEnter(Collider c)
 {
     if (c.gameObject.CompareTag("Player") && c.attachedRigidbody != null)
     {
         //NOTE: inventory script was deleted if more problems arise. This is what we changed
         //InventoryScript invent = c.attachedRigidbody.gameObject.GetComponent<InventoryScript>();
         if (/*invent != null &&*/ botMode == BotMode.Idle)
         {
             botMode = BotMode.Follow;
             anim.SetBool("BootUp", true);
             BotCollector bc = c.attachedRigidbody.gameObject.GetComponent <BotCollector>();
             if (bc != null)
             {
                 bc.ReceiveBots(1, transform.gameObject);
             }
             followTarget = c.attachedRigidbody.transform;
             //invent.AddBot();
         }
     }
     else if (c.gameObject.CompareTag("BotPart") && botMode == BotMode.Follow)
     {
         BotPart botPart = c.GetComponent <BotPart>();
         if (botPart != null)
         {
             GameObject bot = botPart.GetParentBot();
             if (bot != null)
             {
                 BotMovement botScript = bot.GetComponent <BotMovement>();
                 if (botScript != null)
                 {
                     BumpBot(botScript);
                 }
             }
         }
     }
 }
Example #4
0
        public Actor(World world, ActorInit init) : base(init.Position, null)
        {
            World = world;

            Type     = init.Type;
            Team     = init.Team;
            IsPlayer = init.IsPlayer;
            IsBot    = init.IsBot;

            Height = init.Height;

            ID        = init.ID;
            this.init = init;

            CurrentTerrain = world.TerrainAt(TerrainPosition);

            // Parts
            partManager = new PartManager();
            foreach (var partinfo in init.Type.PartInfos)
            {
                if (partinfo is BotPartInfo && !IsBot)
                {
                    continue;
                }

                var part = partinfo.Create(this);
                partManager.Add(part);

                // Cache some important parts
                if (part is MobilePart mobile)
                {
                    Mobile = mobile;
                }
                if (part is MotorPart motor)
                {
                    Motor = motor;
                }
                else if (part is HealthPart health)
                {
                    Health = health;
                }
                else if (part is RevealsShroudPart revealsShroud)
                {
                    RevealsShroud = revealsShroud;
                }
                else if (part is WeaponPart weapon)
                {
                    Weapon = weapon;
                }
                else if (part is WorldPart worldPart)
                {
                    WorldPart = worldPart;
                }
                else if (part is BotPart botPart)
                {
                    Bot = botPart;
                }
                else if (part is PlayerSwitchPart)
                {
                    IsPlayerSwitch = true;
                }
            }

            if (IsBot && Bot == null)
            {
                IsBot = false;                 // BotPart is not there, thus there's no bot
            }
            if (IsPlayer)
            {
                partManager.Add(new PlayerPart(this));
            }

            tickParts         = partManager.GetPartsOrDefault <ITick>();
            editorTickParts   = partManager.GetPartsOrDefault <ITickInEditor>();
            renderParts       = partManager.GetPartsOrDefault <IRenderable>();
            accelerationParts = partManager.GetPartsOrDefault <INoticeAcceleration>();
            moveParts         = partManager.GetPartsOrDefault <INoticeMove>();
            stopParts         = partManager.GetPartsOrDefault <INoticeStop>();

            Physics = Type.Physics == null ? SimplePhysics.Empty : new SimplePhysics(this, Type.Physics.Type);

            if (Health != null && init.Health >= 0f)
            {
                Health.RelativeHP = init.Health;
            }

            var hoverPart = GetPartOrDefault <HoverPart>();

            if (hoverPart != null)
            {
                Height = hoverPart.DefaultHeight;
            }
        }