Exemplo n.º 1
0
    public GameObject enterMechTooltipToHide;     // ignored if null for levels besides #1

    void Awake()
    {
        slopeWalker         = GetComponent <SlopeWalker>();
        slopeWalker.enabled = false;

        Assert.IsNotNull(audioEvent);

        firstIcon  = GameObject.Find("Main UI/Icon Turret").GetComponent <AbilityIcon>();
        secondIcon = GameObject.Find("Main UI/Icon Thrusters").GetComponent <AbilityIcon>();

        mechOnlyMask = LayerMask.GetMask("Mechs");
        playerBody   = GetComponent <Rigidbody2D>();

        spriteRenderer = GetComponent <SpriteRenderer>();
        mainCam        = Camera.main;
        camScript      = mainCam.GetComponent <MainCamera>();

        cursor = UIResourceManager.MouseCursor; // NOTE: ai bots use this class but do not use mouse cursor

        _state = PlayerState.outOfMech;         //default player state, switches between in and out of mech

        jetpack = GetComponent <Jetpack>();

        if (weaponEquipped)   // sanity check: some bots don't have this?
        {
            weapon = weaponEquipped.GetComponent <PlayerMachineGun>();
            weaponManager.GiveWeapon(weapon);
        }

        isAiPlayer = GetComponent <AI>() != null;

        EnableWeapons(true);

        Invoke("SetDefaultIcons", 0.1f);
    }
Exemplo n.º 2
0
 void OnSizeChange(Vector2Int size, Vector2 pixelSize)
 {
     AbilityIcon[] newAbilities = new AbilityIcon[size.x * size.y];
     for (int y = size.y - 1, i = 0; y >= 0; --y)
     {
         float localYCoord = y * (sizeOfAbility + spaceBetween) - pixelSize.y / 2 + (spaceBetween + sizeOfAbility) * 0.5f;
         for (int x = 0; x < size.x; ++x, ++i)
         {
             float localXCoord = x * (sizeOfAbility + spaceBetween) - pixelSize.x / 2 + (spaceBetween + sizeOfAbility) * 0.5f;;
             var   inst        = Instantiate(abilityIconPrefab, transform);
             inst.Instantiate();
             inst.transform.localScale = new Vector3(1 / inst.image.rectTransform.rect.width, 1 / inst.image.rectTransform.rect.height, 1) * sizeOfAbility;
             //  inst.transform.position = (Vector2)transform.position + new Vector2(localXCoord, localYCoord);
             inst.transform.localPosition = new Vector2(localXCoord, localYCoord);
             if (i < abilities.Length && abilities[i].enabled)
             {
                 inst.AttachAbility(abilities[i].attachedAbility);
             }
             else
             {
                 inst.SetInactive();
             }
             newAbilities[i] = inst;
         }
     }
     foreach (var p in abilities)
     {
         Destroy(p.gameObject);
     }
     previosSize = size;
     abilities   = newAbilities;
 }
Exemplo n.º 3
0
 private void Start()
 {
     turnManager     = GetComponent <TurnManager>();
     aIcon           = iconsPanel.GetComponent <AbilityIcon>();
     hIcon           = iconsPanel.GetComponent <HeroIcon>();
     loreInfoText    = LoreInfo.GetComponentInChildren <Text>();
     abilityInfoText = abilityInfo.GetComponentInChildren <Text>();
 }
    Sprite GetIcon(ShipAbility ability)
    {
        AbilityIcon abIcon = abilityIcons.Where(a => a.ability == ability).FirstOrDefault();

        if (abIcon != null)
        {
            return(abIcon.Icon);
        }
        return(null);
    }
Exemplo n.º 5
0
    public override void PlayerComponent_Start()
    {
        if (isLocalPlayer && !myBase.myInput.isBot())
        {
            // Don't want enemy GUIs on top of ours
            GameObject instancedHudPrefab = GameObject.Instantiate(hudPrefab, myBase.myMovement.cameraRotator);
            gameHud   = instancedHudPrefab.GetComponent <GameHudController>();
            healthBar = gameHud.healthBar;
            magicBar  = gameHud.magicBar;
            myBase.myStats.hitAnimator = gameHud.hitMarker;
            spectatorUIController      = GameObject.FindObjectOfType <SpectatorUIController>();
            spectatorUIController.AssignOwner(this.gameObject, UnPauseGameWithoutUI, myBase.myNetworking.playerCameras[0]);
            foreach (Image i in gameHud.teamColoredImages)
            {
                i.color = myBase.myStats.teamColor;
            }
            // Ability icon spawning
            for (int i = 0; i < gameHud.abilityHolder.childCount; i++)
            {
                GameObject.Destroy(gameHud.abilityHolder.GetChild(i).gameObject);
            }
            abilityIcons = new AbilityIcon[myBase.myAbilities.Length];
            int abilityIndex = 0;
            foreach (PlayerAbility ability in myBase.myAbilities)
            {
                AbilityIcon icon = GameObject.Instantiate(gameHud.abilityItemPrefab, gameHud.abilityHolder).GetComponent <AbilityIcon>();
                foreach (Image i in icon.teamColoredImages)
                {
                    i.color = myBase.myStats.teamColor;
                }
                //print ("ability: " + ability + " icon: " + icon);
                icon.keyText.text = abilityText [abilityIndex];
                if (ability.abilitySprite != null)
                {
                    icon.abilityIcon.sprite     = ability.abilitySprite;
                    icon.backgroundImage.sprite = ability.abilitySprite;
                }
                abilityIcons [abilityIndex] = icon;
                ability.SetIcon(icon);
                CooldownAbility cooldownAbility;
                if (ability is CooldownAbility && (cooldownAbility = (CooldownAbility)ability))
                {
                    cooldownAbility.SetIcon(icon);
                }
                abilityIndex++;
            }

            UnPauseGame();
        }
        else
        {
        }
    }
Exemplo n.º 6
0
 public void DisplayAbility(AbilityTypes a, Sprite s)
 {
     if (free.Count == 0)
     {
         Debug.LogError("AbilityDisplay::DisplayAbility: free is empty");
         return;
     }
     if (indxForAbility [(int)a] == -1)
     {
         AbilityIcon iconAdded = free[free.Count - 1];
         free.RemoveAt(free.Count - 1);
         slots.Add(iconAdded);
         iconAdded.Begin(s, a, slots.Count - 1);
         indxForAbility [(int)a] = slots.Count - 1;
     }
 }
        public override void LoadContent()
        {
            base.LoadContent();

            texTarget      = Content.Load <Texture2D>("Target");
            texTest        = Content.Load <Texture2D>("SShip4m");
            texPixel       = Content.Load <Texture2D>("pixel");
            texMouseCursor = Content.Load <Texture2D>("sword_02");
            spriteFontFile = Content.Load <SpriteFont>("File");

            texPlayerDoubleJump = Content.Load <Texture2D>("doublejump");
            texPlayerDash       = Content.Load <Texture2D>("dash");
            texPlayerSlice      = Content.Load <Texture2D>("slice2");

            Slice.pixel            = texPixel;
            EnemyHitbox.texHitbox  = texPixel;
            TestEnemy.texTestEnemy = texTarget;
            Player.texPlayer       = texPixel;

            particleList = new RC_RenderableList();
            sliceList    = new SpriteList();
            platformList = new SpriteList();
            enemyList    = new SpriteList();

            //Initialize abilities
            abilityIconDoubleJump = new AbilityIcon(texPlayerDoubleJump, new Vector2(900, Game1.SCREEN_HEIGHT - 100));
            abilityIconDash       = new AbilityIcon(texPlayerDash, new Vector2(1000, Game1.SCREEN_HEIGHT - 100));
            abilityIconSlice      = new AbilityIcon(texPlayerSlice, new Vector2(800, Game1.SCREEN_HEIGHT - 100));

            Player.iconDoubleJump = abilityIconDoubleJump;
            Player.iconDash       = abilityIconDash;
            Player.iconSlice      = abilityIconSlice;

            //player = new Player(new Vector2(100, 100));
            //LoadLevel();

            //ResetPlayer();

            //cam.Pos = new Vector2(0, 0);

            ////cam.Zoom = 2.0f // Example of Zoom in
            //cam.Zoom = 1f; // Example of Zoom out

            //SpawnTargets();
        }
Exemplo n.º 8
0
    public void Remove(AbilityTypes t)
    {
        int i = indxForAbility [(int)t];

        if (i < 0 || i >= slots.Count)
        {
            Debug.LogError("AbilityDisplay::Remove(" + t.ToString() + ") has indxForAbility = " + i.ToString() + " and slots.Count is " + slots.Count.ToString());
            return;
        }
        AbilityIcon icon = slots[i];

        icon.Fade();
        slots.RemoveAt(i);
        free.Add(icon);
        indxForAbility [(int)t] = -1;
        for (int j = i; j < slots.Count; ++j)
        {
            slots [j].ShiftLeft();
            --indxForAbility [(int)slots [j].Type()];
        }
    }
Exemplo n.º 9
0
 private void Awake()
 {
     singleton = this;
     abilities = new AbilityIcon[0];
 }
Exemplo n.º 10
0
    public abstract void use();            // Called when either your input or the server tells you to use these

    public void SetIcon(AbilityIcon icon)
    {
        abilityIcon = icon;
    }